Skip to content

Commit 2149914

Browse files
authored
[Clang][Parser] Build up QualifiedTemplateName for typo correction (#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
1 parent ed41497 commit 2149914

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ Bug Fixes to C++ Support
381381
- Fixed a bug where defaulted comparison operators would remove ``const`` from base classes. (#GH102588)
382382
- Fix a crash when using ``source_location`` in the trailing return type of a lambda expression. (#GH67134)
383383
- A follow-up fix was added for (#GH61460), as the previous fix was not entirely correct. (#GH86361)
384+
- Fixed a crash in the typo correction of an invalid CTAD guide. (#GH107887)
384385

385386
Bug Fixes to AST Handling
386387
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Sema/SemaTemplate.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3567,7 +3567,9 @@ bool Sema::resolveAssumedTemplateNameAsType(Scope *S, TemplateName &Name,
35673567
if (Corrected && Corrected.getFoundDecl()) {
35683568
diagnoseTypo(Corrected, PDiag(diag::err_no_template_suggest)
35693569
<< ATN->getDeclName());
3570-
Name = TemplateName(Corrected.getCorrectionDeclAs<TemplateDecl>());
3570+
Name = Context.getQualifiedTemplateName(
3571+
/*NNS=*/nullptr, /*TemplateKeyword=*/false,
3572+
TemplateName(Corrected.getCorrectionDeclAs<TemplateDecl>()));
35713573
return false;
35723574
}
35733575

clang/test/Parser/cxx1z-class-template-argument-deduction.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,15 @@ void f() {
255255
GH57495::vector.d; // expected-error {{cannot use dot operator on a type}}
256256
}
257257
}
258+
259+
namespace GH107887 {
260+
261+
namespace a {
262+
template <class> struct pair; // expected-note 3{{declared here}}
263+
}
264+
template <class T2> pair() -> pair<T2>; // expected-error 2{{no template named 'pair'}} \
265+
// expected-error {{deduction guide must be declared in the same scope}} \
266+
// expected-error {{cannot be deduced}} \
267+
// expected-note {{non-deducible template parameter 'T2'}}
268+
269+
}

0 commit comments

Comments
 (0)