Skip to content

Commit

Permalink
[Clang][Parser] Build up QualifiedTemplateName for typo correction (#…
Browse files Browse the repository at this point in the history
…108148)

Since #93433, we have switched to `QualifiedTemplateName`s in more
situations to preserve sugars in diagnostics. However, there is one
missed case in typo correction that might not meet the expectation in
`CheckDeductionGuideDeclarator()`.

Fixes #107887
  • Loading branch information
zyn0217 authored Sep 12, 2024
1 parent ed41497 commit 2149914
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ Bug Fixes to C++ Support
- Fixed a bug where defaulted comparison operators would remove ``const`` from base classes. (#GH102588)
- Fix a crash when using ``source_location`` in the trailing return type of a lambda expression. (#GH67134)
- A follow-up fix was added for (#GH61460), as the previous fix was not entirely correct. (#GH86361)
- Fixed a crash in the typo correction of an invalid CTAD guide. (#GH107887)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
4 changes: 3 additions & 1 deletion clang/lib/Sema/SemaTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3567,7 +3567,9 @@ bool Sema::resolveAssumedTemplateNameAsType(Scope *S, TemplateName &Name,
if (Corrected && Corrected.getFoundDecl()) {
diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest)
<< ATN->getDeclName());
Name = TemplateName(Corrected.getCorrectionDeclAs<TemplateDecl>());
Name = Context.getQualifiedTemplateName(
/*NNS=*/nullptr, /*TemplateKeyword=*/false,
TemplateName(Corrected.getCorrectionDeclAs<TemplateDecl>()));
return false;
}

Expand Down
12 changes: 12 additions & 0 deletions clang/test/Parser/cxx1z-class-template-argument-deduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,15 @@ void f() {
GH57495::vector.d; // expected-error {{cannot use dot operator on a type}}
}
}

namespace GH107887 {

namespace a {
template <class> struct pair; // expected-note 3{{declared here}}
}
template <class T2> pair() -> pair<T2>; // expected-error 2{{no template named 'pair'}} \
// expected-error {{deduction guide must be declared in the same scope}} \
// expected-error {{cannot be deduced}} \
// expected-note {{non-deducible template parameter 'T2'}}

}

0 comments on commit 2149914

Please sign in to comment.