[clang] [Clang][Sema] Create LocalScope for Variable Template (PR #228280)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 3 20:15:14 PDT 2026


================
@@ -6355,6 +6355,10 @@ VarTemplateSpecializationDecl *Sema::BuildVarTemplateInstantiation(
   if (Inst.isInvalid())
     return nullptr;
 
+  // A variable template specialization is never a local declaration, so it
+  // must not see the locals of whatever instantiation we are currently in.
+  LocalInstantiationScope Local(*this);
----------------
zyn0217 wrote:

I meant, FindInstantiatedDecl could find instantiated decls if CurContext is already set up properly!



https://github.com/llvm/llvm-project/pull/228280


More information about the cfe-commits mailing list