https://github.com/sdkrystian updated https://github.com/llvm/llvm-project/pull/115157
>From d36ee37cdba49332d36ab8204826e50614359e82 Mon Sep 17 00:00:00 2001 From: Krystian Stasiowski <sdkryst...@gmail.com> Date: Wed, 6 Nov 2024 08:36:04 -0500 Subject: [PATCH] Revert "[Clang][Sema] Use the correct injected template arguments for partial specializations when collecting multi-level template argument lists (#112381)" This reverts commit 9381c6fd04cc16a7606633f57c96c11e58181ddb. --- clang/lib/Sema/SemaTemplateInstantiate.cpp | 6 +- .../temp/temp.constr/temp.constr.decl/p4.cpp | 284 ++++++++---------- 2 files changed, 122 insertions(+), 168 deletions(-) diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp b/clang/lib/Sema/SemaTemplateInstantiate.cpp index b63063813f1b56..c5921287a3afb2 100644 --- a/clang/lib/Sema/SemaTemplateInstantiate.cpp +++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp @@ -237,8 +237,7 @@ struct TemplateInstantiationArgumentCollecter if (Innermost) AddInnermostTemplateArguments(VTPSD); else if (ForConstraintInstantiation) - AddOuterTemplateArguments(VTPSD, - VTPSD->getInjectedTemplateArgs(S.Context), + AddOuterTemplateArguments(VTPSD, VTPSD->getTemplateArgs().asArray(), /*Final=*/false); if (VTPSD->isMemberSpecialization()) @@ -275,8 +274,7 @@ struct TemplateInstantiationArgumentCollecter if (Innermost) AddInnermostTemplateArguments(CTPSD); else if (ForConstraintInstantiation) - AddOuterTemplateArguments(CTPSD, - CTPSD->getInjectedTemplateArgs(S.Context), + AddOuterTemplateArguments(CTPSD, CTPSD->getTemplateArgs().asArray(), /*Final=*/false); if (CTPSD->isMemberSpecialization()) diff --git a/clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp b/clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp index f144e14cd122f9..70064f867e18e3 100644 --- a/clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp +++ b/clang/test/CXX/temp/temp.constr/temp.constr.decl/p4.cpp @@ -1,219 +1,175 @@ // RUN: %clang_cc1 -std=c++20 -verify %s // expected-no-diagnostics -namespace Primary { - template<typename T> - concept D = true; +template<typename T> +concept D = true; - template<typename T> - struct A { - template<typename U, bool V> - void f() requires V; - - template<> - void f<short, true>(); - - template<D U> - void g(); - - template<typename U, bool V> requires V - struct B; - - template<typename U, bool V> requires V - struct B<U*, V>; - - template<> - struct B<short, true>; - - template<D U> - struct C; - - template<D U> - struct C<U*>; - - template<typename U, bool V> requires V - static int x; - - template<typename U, bool V> requires V - static int x<U*, V>; - - template<> - int x<short, true>; - - template<D U> - static int y; - - template<D U> - static int y<U*>; - }; - - template<typename T> +template<typename T> +struct A { template<typename U, bool V> - void A<T>::f() requires V { } + void f() requires V; + + template<> + void f<short, true>(); - template<typename T> template<D U> - void A<T>::g() { } + void g(); - template<typename T> template<typename U, bool V> requires V - struct A<T>::B { }; + struct B; - template<typename T> template<typename U, bool V> requires V - struct A<T>::B<U*, V> { }; + struct B<U*, V>; - template<typename T> - template<typename U, bool V> requires V - struct A<T>::B<U&, V> { }; + template<> + struct B<short, true>; - template<typename T> template<D U> - struct A<T>::C { }; + struct C; - template<typename T> template<D U> - struct A<T>::C<U*> { }; + struct C<U*>; - template<typename T> template<typename U, bool V> requires V - int A<T>::x = 0; + static int x; - template<typename T> template<typename U, bool V> requires V - int A<T>::x<U*, V> = 0; + static int x<U*, V>; - template<typename T> - template<typename U, bool V> requires V - int A<T>::x<U&, V> = 0; + template<> + int x<short, true>; - template<typename T> template<D U> - int A<T>::y = 0; + static int y; - template<typename T> template<D U> - int A<T>::y<U*> = 0; + static int y<U*>; +}; - template<> - template<typename U, bool V> - void A<short>::f() requires V; +template<typename T> +template<typename U, bool V> +void A<T>::f() requires V { } - template<> - template<> - void A<short>::f<int, true>(); +template<typename T> +template<D U> +void A<T>::g() { } - template<> - template<> - void A<void>::f<int, true>(); +template<typename T> +template<typename U, bool V> requires V +struct A<T>::B { }; - template<> - template<D U> - void A<short>::g(); +template<typename T> +template<typename U, bool V> requires V +struct A<T>::B<U*, V> { }; - template<> - template<typename U, bool V> requires V - struct A<int>::B; +template<typename T> +template<typename U, bool V> requires V +struct A<T>::B<U&, V> { }; - template<> - template<> - struct A<int>::B<int, true>; +template<typename T> +template<D U> +struct A<T>::C { }; - template<> - template<> - struct A<void>::B<int, true>; +template<typename T> +template<D U> +struct A<T>::C<U*> { }; - template<> - template<typename U, bool V> requires V - struct A<int>::B<U*, V>; +template<typename T> +template<typename U, bool V> requires V +int A<T>::x = 0; - template<> - template<typename U, bool V> requires V - struct A<int>::B<U&, V>; +template<typename T> +template<typename U, bool V> requires V +int A<T>::x<U*, V> = 0; - template<> - template<D U> - struct A<int>::C; +template<typename T> +template<typename U, bool V> requires V +int A<T>::x<U&, V> = 0; - template<> - template<D U> - struct A<int>::C<U*>; +template<typename T> +template<D U> +int A<T>::y = 0; - template<> - template<D U> - struct A<int>::C<U&>; +template<typename T> +template<D U> +int A<T>::y<U*> = 0; - template<> - template<typename U, bool V> requires V - int A<long>::x; +template<> +template<typename U, bool V> +void A<short>::f() requires V; - template<> - template<> - int A<long>::x<int, true>; +template<> +template<> +void A<short>::f<int, true>(); - template<> - template<> - int A<void>::x<int, true>; +template<> +template<> +void A<void>::f<int, true>(); - template<> - template<typename U, bool V> requires V - int A<long>::x<U*, V>; +template<> +template<D U> +void A<short>::g(); - template<> - template<typename U, bool V> requires V - int A<long>::x<U&, V>; +template<> +template<typename U, bool V> requires V +struct A<int>::B; - template<> - template<D U> - int A<long>::y; +template<> +template<> +struct A<int>::B<int, true>; - template<> - template<D U> - int A<long>::y<U*>; +template<> +template<> +struct A<void>::B<int, true>; - template<> - template<D U> - int A<long>::y<U&>; -} // namespace Primary +template<> +template<typename U, bool V> requires V +struct A<int>::B<U*, V>; -namespace Partial { - template<typename T, bool B> - struct A; +template<> +template<typename U, bool V> requires V +struct A<int>::B<U&, V>; - template<bool U> - struct A<int, U> - { - template<typename V> requires U - void f(); +template<> +template<D U> +struct A<int>::C; - template<typename V> requires U - static const int x; +template<> +template<D U> +struct A<int>::C<U*>; - template<typename V> requires U - struct B; - }; +template<> +template<D U> +struct A<int>::C<U&>; - template<bool U> - template<typename V> requires U - void A<int, U>::f() { } +template<> +template<typename U, bool V> requires V +int A<long>::x; - template<bool U> - template<typename V> requires U - constexpr int A<int, U>::x = 0; +template<> +template<> +int A<long>::x<int, true>; - template<bool U> - template<typename V> requires U - struct A<int, U>::B { }; +template<> +template<> +int A<void>::x<int, true>; - template<> - template<typename V> requires true - void A<int, true>::f() { } +template<> +template<typename U, bool V> requires V +int A<long>::x<U*, V>; - template<> - template<typename V> requires true - constexpr int A<int, true>::x = 1; +template<> +template<typename U, bool V> requires V +int A<long>::x<U&, V>; - template<> - template<typename V> requires true - struct A<int, true>::B { }; -} // namespace Partial +template<> +template<D U> +int A<long>::y; + +template<> +template<D U> +int A<long>::y<U*>; + +template<> +template<D U> +int A<long>::y<U&>; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits