https://github.com/zwuis created https://github.com/llvm/llvm-project/pull/139490
Workaround for #139067 >From c5a9cda3e5c3aa2b07281e373e9736045a01643b Mon Sep 17 00:00:00 2001 From: Yanzuo Liu <zw...@outlook.com> Date: Mon, 12 May 2025 11:08:50 +0800 Subject: [PATCH] Disable checking invalid template id in primary variable template initializer --- clang/lib/Sema/SemaTemplate.cpp | 3 +++ clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 7940340064eda..365c61949379d 100644 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -4382,6 +4382,8 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, return Context.isSameTemplateArgument(Arg1, Arg2); }; +// Workaround for GH139067 / https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120190 +#if 0 if (VarDecl *Var = Template->getTemplatedDecl(); ParsingInitForAutoVars.count(Var) && llvm::equal( @@ -4393,6 +4395,7 @@ Sema::CheckVarTemplateId(VarTemplateDecl *Template, SourceLocation TemplateLoc, << diag::ParsingInitFor::VarTemplate << Var << Var->getType(); return true; } +#endif SmallVector<VarTemplatePartialSpecializationDecl *, 4> PartialSpecs; Template->getPartialSpecializations(PartialSpecs); diff --git a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp index 1fe0ce9aabf29..a60d723e477c4 100644 --- a/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp +++ b/clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp @@ -495,12 +495,12 @@ static_assert(C<int, 0,1,2,3,4>::VALUEARRAY[0] == 0, ""); namespace appear_in_its_own_init { template <class T> -auto GH51347 = GH51347<T>; // expected-error {{variable template 'GH51347' declared with deduced type 'auto' cannot appear in its own initializer}} +auto GH51347 = GH51347<T>; template <class T, class... Ts> auto a = [] { using U = T; - a<U, Ts...>; // expected-error {{variable template 'a' declared with deduced type 'auto' cannot appear in its own initializer}} + a<U, Ts...>; }; template <int...> int b; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits