[llvm-branch-commits] [clang] [clang] create local instantiation scope for matching template template parameters (PR #183817)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Feb 27 11:54:40 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)

<details>
<summary>Changes</summary>

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

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaTemplateDeduction.cpp (+2) 
- (modified) clang/test/SemaTemplate/temp_arg_template_p0522.cpp (+7) 


``````````diff
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

``````````

</details>


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


More information about the llvm-branch-commits mailing list