diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 250821a9f9c45..9f253d80b2b64 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -378,6 +378,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 ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 513f83146fb59..e5ea02a919f4e 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -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()); + Name = Context.getQualifiedTemplateName( + /*NNS=*/nullptr, /*TemplateKeyword=*/false, + TemplateName(Corrected.getCorrectionDeclAs())); return false; } diff --git a/clang/test/Parser/cxx1z-class-template-argument-deduction.cpp b/clang/test/Parser/cxx1z-class-template-argument-deduction.cpp index 2dd61baac31b3..a1594333abae7 100644 --- a/clang/test/Parser/cxx1z-class-template-argument-deduction.cpp +++ b/clang/test/Parser/cxx1z-class-template-argument-deduction.cpp @@ -255,3 +255,15 @@ void f() { GH57495::vector.d; // expected-error {{cannot use dot operator on a type}} } } + +namespace GH107887 { + +namespace a { +template struct pair; // expected-note 3{{declared here}} +} +template pair() -> pair; // 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'}} + +}