[llvm-branch-commits] [clang] b1b0bb9 - [clang] create local instantiation scope for matching template template parameters

Douglas Yung via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sat Feb 28 01:21:14 PST 2026


Author: Matheus Izvekov
Date: 2026-02-28T09:21:02Z
New Revision: b1b0bb934d2046290b7e2ddbb4f63089538ec859

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

LOG: [clang] create local instantiation scope for matching template template parameters

This fixes a bug where a partial substitution from the enclosing scope
is used to prepopulate an unrelated template argument deduction.

Backport from #183219

Fixes #181166

Added: 
    

Modified: 
    clang/lib/Sema/SemaTemplateDeduction.cpp
    clang/test/SemaTemplate/temp_arg_template_p0522.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp b/clang/lib/Sema/SemaTemplateDeduction.cpp
index a287319cc4f88..0476872e282cf 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -6501,6 +6501,8 @@ bool Sema::isTemplateTemplateParameterAtLeastAsSpecializedAs(
   if (Inst.isInvalid())
     return false;
 
+  LocalInstantiationScope Scope(*this);
+
   //   Given an invented class template X with the template parameter list of
   //   A (including default arguments):
   //    - Each function template has a single function parameter whose type is

diff  --git a/clang/test/SemaTemplate/temp_arg_template_p0522.cpp b/clang/test/SemaTemplate/temp_arg_template_p0522.cpp
index 60d98a653ff02..bde811c3bf685 100644
--- a/clang/test/SemaTemplate/temp_arg_template_p0522.cpp
+++ b/clang/test/SemaTemplate/temp_arg_template_p0522.cpp
@@ -168,3 +168,10 @@ namespace GH101394 {
     // expected-note@#B  {{passing argument to parameter here}}
   } // namespace t2
 } // namespace GH101394
+
+namespace GH181166 {
+  template <template <class...> class> struct A;
+  template <template <class...> class... TT1> A<TT1...> f();
+  template <class ...Ts> struct B {};
+  using T = decltype(f<B>());
+} // namespace GH181166


        


More information about the llvm-branch-commits mailing list