|
2 | 2 | // FIXME: RUN: %clang_cc1 -std=c++2c -x c++ -verify %s
|
3 | 3 |
|
4 | 4 | template<typename T> concept True = true;
|
5 |
| -template<typename T> concept Foo = True<T*>; |
6 |
| -template<typename T> concept Bar = Foo<T&>; |
7 |
| -template<typename T> requires Bar<T> struct S { }; |
8 |
| -// FIXME: GCC rejects: https://gcc.godbolt.org/z/c9G7G6PTx if the specialization is present. |
| 5 | +template<typename T> concept Foo = True<T*>; // #Foo |
| 6 | +template<typename T> concept Bar = Foo<T&>; // #Bar |
| 7 | +template<typename T> requires Bar<T> struct S { }; // #S |
9 | 8 | template<typename T> requires Bar<T> && true struct S<T> { };
|
| 9 | +// expected-error@-1 {{class template partial specialization is not more specialized than the primary template}} |
| 10 | +// expected-error@#Foo 2{{'type name' declared as a pointer to a reference of type 'T &'}} |
| 11 | +// expected-note@#Foo 2{{while substituting into concept arguments here}} |
| 12 | +// expected-note@#Bar 2{{while substituting into concept arguments here}} |
| 13 | +// expected-note@#S {{template is declared here}} |
| 14 | + |
| 15 | + |
10 | 16 |
|
11 | 17 | template<typename T> concept True2 = sizeof(T) >= 0;
|
12 |
| -template<typename T> concept Foo2 = True2<T*>; |
13 |
| -// expected-error@-1 3{{'type name' declared as a pointer to a reference of type 'type-parameter-0-0 &'}} |
14 |
| -template<typename T> concept Bar2 = Foo2<T&>; |
| 18 | +template<typename T> concept Foo2 = True2<T*>; // #Foo2 |
| 19 | + |
| 20 | +template<typename T> concept Bar2 = Foo2<T&>; // #Bar2 |
15 | 21 | // expected-note@-1 3{{while substituting into concept arguments here; substitution failures not allowed in concept arguments}}
|
16 | 22 | template<typename T> requires Bar2<T> struct S2 { };
|
17 | 23 | // expected-note@-1{{template is declared here}}
|
18 | 24 | template<typename T> requires Bar2<T> && true struct S2<T> { };
|
19 | 25 | // expected-error@-1{{class template partial specialization is not more specialized than the primary template}}
|
20 |
| -// expected-note@-2{{while calculating associated constraint of template 'S2<T>' here}} |
| 26 | +// expected-error@#Foo2{{'type name' declared as a pointer to a reference of type 'T &'}} |
| 27 | + |
21 | 28 |
|
22 | 29 | namespace type_pack {
|
23 | 30 | template<typename... Args>
|
@@ -73,16 +80,29 @@ namespace non_type_pack {
|
73 | 80 | namespace PR47174 {
|
74 | 81 | // This checks that we don't crash with a failed substitution on the first constrained argument when
|
75 | 82 | // performing normalization.
|
76 |
| -template <Bar2 T, True U> // expected-note {{while calculating associated constraint of template 'S3' here}} |
| 83 | +template <Bar2 T, True U> |
77 | 84 | requires true struct S3; // expected-note {{template is declared here}}
|
78 | 85 | template <True T, True U>
|
79 |
| -requires true struct S3<T, U>; // expected-error {{class template partial specialization is not more specialized than the primary template}} |
| 86 | +requires true struct S3<T, U>; |
| 87 | +// expected-error@-1 {{class template partial specialization is not more specialized than the primary template}} |
| 88 | +// expected-error@#Foo2 2{{'type name' declared as a pointer to a reference of type 'T &'}} |
| 89 | +// expected-note@#Foo2 2{{while substituting into concept arguments here}} |
| 90 | +// expected-note@#Bar2 {{while substituting into concept arguments here}} |
| 91 | + |
80 | 92 |
|
81 | 93 | // Same as above, for the second position (but this was already working).
|
82 |
| -template <True T, Bar2 U> // expected-note {{while calculating associated constraint of template 'S4' here}} |
83 |
| -requires true struct S4; // expected-note {{template is declared here}} |
| 94 | +template <True T, Bar2 U> |
| 95 | +requires true struct S4; // #S4 |
84 | 96 | template <True T, True U>
|
85 |
| -requires true struct S4<T, U>; // expected-error {{class template partial specialization is not more specialized than the primary template}} |
| 97 | +requires true struct S4<T, U>; // #S4-spec |
| 98 | +// expected-error@-1 {{class template partial specialization is not more specialized than the primary template}} |
| 99 | +// expected-error@#Foo2 {{'type name' declared as a pointer to a reference of type 'U &'}} |
| 100 | +// expected-note@#Foo2 2{{while substituting into concept arguments here}} |
| 101 | +// expected-note@#S4 {{template is declared here}} |
| 102 | +// expected-note@#S4 {{similar constraint expressions not considered equivalent}} |
| 103 | +// expected-note@#S4-spec {{similar constraint expression here}} |
| 104 | + |
| 105 | + |
86 | 106 |
|
87 | 107 | struct X {
|
88 | 108 | template<int> struct Y {
|
|
0 commit comments