https://github.com/dyung updated https://github.com/llvm/llvm-project/pull/183823
>From cb79aaed35b08a38846c5a09448870c673a88b43 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov <[email protected]> Date: Tue, 24 Feb 2026 21:51:13 -0300 Subject: [PATCH] [clang] Backport: allow canonicalizing assumed template names Assumed template names are part of error recovery and encode just a declaration name, making them always canonical. This patch allows them to be canonicalized, which is trivial. Backport from #183222 Fixes #183075 --- clang/lib/AST/ASTContext.cpp | 7 +++++-- clang/test/SemaTemplate/GH183075.cpp | 13 +++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 clang/test/SemaTemplate/GH183075.cpp diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index f52470a4d7458..100e37c131ef2 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -7244,9 +7244,12 @@ TemplateName ASTContext::getCanonicalTemplateName(TemplateName Name, return TemplateName(cast<TemplateDecl>(Template->getCanonicalDecl())); } - case TemplateName::OverloadedTemplate: case TemplateName::AssumedTemplate: - llvm_unreachable("cannot canonicalize unresolved template"); + // An assumed template is just a name, so it is already canonical. + return Name; + + case TemplateName::OverloadedTemplate: + llvm_unreachable("cannot canonicalize overloaded template"); case TemplateName::DependentTemplate: { DependentTemplateName *DTN = Name.getAsDependentTemplateName(); diff --git a/clang/test/SemaTemplate/GH183075.cpp b/clang/test/SemaTemplate/GH183075.cpp new file mode 100644 index 0000000000000..a9aa7d7a2157a --- /dev/null +++ b/clang/test/SemaTemplate/GH183075.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -verify %s + +int bar; // #bar + +int foo() +{ + // FIXME: Bad error recovery. + (void)(baz<> + baz<>); + // expected-error@-1 2{{use of undeclared identifier 'baz'; did you mean 'bar'?}} + // expected-note@#bar 2{{'bar' declared here}} + // expected-error@-3 2{{'bar' is expected to be a non-type template, but instantiated to a class template}} + // expected-note@#bar 2{{class template declared here}} +} _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
