[LoongArch] Update lld20 release notes
[llvm-project.git] / clang / test / CXX / temp / temp.constr / temp.constr.order / class-template-partial-specializations.cpp
blob7772eecc69be8b126d43b97e4723ac1c9962ddde
1 // RUN: %clang_cc1 -std=c++2a -x c++ -verify %s
3 template<typename T> requires (sizeof(T) >= 4)
4 // expected-note@-1{{similar constraint expressions not considered equivalen}}
5 class A{}; // expected-note{{template is declared here}}
7 template<typename T> requires (sizeof(T) >= 4 && sizeof(T) <= 10)
8 // expected-note@-1{{similar constraint expression here}}
10 class A<T>{}; // expected-error{{class template partial specialization is not more specialized than the primary template}}
12 template<typename T>
13 concept C1 = sizeof(T) >= 4;
15 template<typename T> requires C1<T>
16 class B{};
18 template<typename T> requires (C1<T> && sizeof(T) <= 10)
19 class B<T>{};
21 template<typename T>
22 concept C2 = sizeof(T) > 1 && sizeof(T) <= 8;
24 template<typename T>
25 class C{};
27 template<typename T> requires C1<T>
28 class C<T>{};
30 template<typename T>
31 class D{}; // expected-note{{previous definition is here}}
33 template<typename T>
34 class D<T>{}; // expected-error{{class template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}} expected-error{{redefinition of 'D'}}
36 template<typename T> requires C1<T> // expected-note{{previous template declaration is here}}
37 class E{};
39 template<typename T> // expected-error{{requires clause differs in template redeclaration}}
40 class E<T>{}; // expected-error{{class template partial specialization does not specialize any template argument; to define the primary template, remove the template argument list}}
42 template<typename T>
43 struct F{ enum{ value = 1 }; };
45 template<typename T> requires C1<T> && C2<T>
46 struct F<T>{ enum{ value = 2 }; };
48 template<typename T> requires C1<T> || C2<T>
49 struct F<T>{ enum{ value = 3 }; };
51 static_assert(F<unsigned>::value == 2);
52 static_assert(F<char[10]>::value == 3);
53 static_assert(F<char>::value == 1);
55 template <unsigned I>
56 struct S {
57 template <typename T>
58 struct F {
59 enum { value = 1 };
62 template <typename T>
63 requires C1<T> && C2<T>
64 struct F<T> {
65 enum { value = 2 };
68 template <typename T>
69 requires C1<T> || C2<T>
70 struct F<T> {
71 enum { value = 3 };
75 static_assert(S<1>::F<unsigned>::value == 2);
76 static_assert(S<1>::F<char[10]>::value == 3);
77 static_assert(S<1>::F<char>::value == 1);
79 // Make sure atomic constraints subsume each other only if their parameter
80 // mappings are identical.
82 template<typename T, typename U> requires C2<T>
83 struct I { }; // expected-note {{template is declared here}}
85 template<typename T, typename U> requires C2<U>
86 struct I<T, U> { }; // expected-error {{class template partial specialization is not more specialized than the primary template}}
88 template<typename T, typename U> requires C2<T> && C2<U>
89 struct I<T, U> { };