https://github.com/mizvekov created https://github.com/llvm/llvm-project/pull/183817
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 >From c5ddaa241c71c4d38642d982496d7a4343236b04 Mon Sep 17 00:00:00 2001 From: Matheus Izvekov <[email protected]> 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 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
