Skip to content

[Clang][Sema] Disable checking invalid template id in primary variable template initializer #139490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

zwuis
Copy link
Contributor

@zwuis zwuis commented May 12, 2025

Workaround for #139067

@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels May 12, 2025
@llvmbot
Copy link
Member

llvmbot commented May 12, 2025

@llvm/pr-subscribers-clang

Author: Yanzuo Liu (zwuis)

Changes

Workaround for #139067


Full diff: https://github.com/llvm/llvm-project/pull/139490.diff

2 Files Affected:

  • (modified) clang/lib/Sema/SemaTemplate.cpp (+3)
  • (modified) clang/test/SemaCXX/cxx1y-variable-templates_top_level.cpp (+2-2)
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;

Copy link
Contributor

@zyn0217 zyn0217 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we would prefer a revert than adding dead blocks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants