Author: Younan Zhang
Date: 2026-11-02T16:46:13+08:00
New Revision: e65c9f4a7176163a6843efa7d868b35a4e74db96

URL: 
https://github.com/llvm/llvm-project/commit/e65c9f4a7176163a6843efa7d868b35a4e74db96
DIFF: 
https://github.com/llvm/llvm-project/commit/e65c9f4a7176163a6843efa7d868b35a4e74db96.diff

LOG: [Clang] Fix variable template instantiation (#237843)

We always consider undeduced specializations as NeedDefinition, despite
UsableInConstantExpr.

Fixes https://github.com/llvm/llvm-project/issues/116319

Added: 
    

Modified: 
    clang/lib/Sema/SemaExpr.cpp
    clang/test/CodeGenCXX/gh56652.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 00dd8acf1f68dd..a14c3d50d12851 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -21052,8 +21052,7 @@ static void DoMarkVarDeclReferenced(
 
   bool NeedDefinition =
       OdrUse == OdrUseContext::Used || NeededForConstantEvaluation ||
-      (TSK != clang::TSK_Undeclared && !UsableInConstantExpr &&
-       Var->getType()->isUndeducedType());
+      (TSK != clang::TSK_Undeclared && Var->getType()->isUndeducedType());
 
   assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
          "Can't instantiate a partial template specialization.");

diff  --git a/clang/test/CodeGenCXX/gh56652.cpp 
b/clang/test/CodeGenCXX/gh56652.cpp
index 06a496e320bfc1..04616cca0c0913 100644
--- a/clang/test/CodeGenCXX/gh56652.cpp
+++ b/clang/test/CodeGenCXX/gh56652.cpp
@@ -33,6 +33,7 @@ template <class> static void c() noexcept(noexcept(b<int>)) {}
 
 void test() { a<>::c<int>(); }
 
+static_assert(sizeof(a<>::b<int>) == sizeof(int));
 
 }
 


        
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to