git: fe9c7137871e - main - Merge commit c4ce37507537 from llvm-project (by ShengYi Hung):

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sat, 03 Oct 2026 11:37:58 UTC
The branch main has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=fe9c7137871ee0b5c48d4c38b87d80f72e73379e

commit fe9c7137871ee0b5c48d4c38b87d80f72e73379e
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2026-10-03 11:36:42 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2026-10-03 11:37:43 +0000

    Merge commit c4ce37507537 from llvm-project (by ShengYi Hung):
    
      [Clang][Sema] Create LocalScope for Variable Template (#228280)
    
      A variable template should create its own LocalScope, as it should be
      opaque to other instantiations. This can occur when there are multiple
      instantiations in the same lexical scope. The correct behavior is that
      these instantiations should not be chained together.
    
      Assisted-by: Claude # Test ReleaseNote
      Fixes: #134148
    
    This fixes an assertion while building the devel/glaze port.
    
    PR:             276265
    MFC after:      3 days
---
 contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp b/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index d2b87f2702a9..a9755bcc73fe 100644
--- a/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/contrib/llvm-project/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -5901,6 +5901,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);
+
   // Instantiate the first declaration of the variable template: for a partial
   // specialization of a static data member template, the first declaration may
   // or may not be the declaration in the class; if it's in the class, we want