[llvm-branch-commits] [clang] [clang] Backport: create local instantiation scope for matching template template parameters (PR #183817)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sat Feb 28 01:21:14 PST 2026
https://github.com/dyung updated https://github.com/llvm/llvm-project/pull/183817
>From b1b0bb934d2046290b7e2ddbb4f63089538ec859 Mon Sep 17 00:00:00 2001
From: Matheus Izvekov <mizvekov at gmail.com>
Date: Tue, 24 Feb 2026 19:20:23 -0300
Subject: [PATCH] [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
---
clang/lib/Sema/SemaTemplateDeduction.cpp | 2 ++
clang/test/SemaTemplate/temp_arg_template_p0522.cpp | 7 +++++++
2 files changed, 9 insertions(+)
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