152
|
1 // { dg-do compile { target c++2a } }
|
|
2 // { dg-additional-options "-fconcepts-diagnostics-depth=2" }
|
|
3
|
|
4 template<typename T>
|
|
5 concept c1 = requires { typename T::blah; };
|
|
6 // { dg-message "satisfaction of .c1<T>. .with T = char." "" { target *-*-* } .-1 }
|
|
7 // { dg-message ".typename T::blah. is invalid" "" { target *-*-* } .-2 }
|
|
8
|
|
9 template<typename T>
|
|
10 concept c2 = requires (T x) { *x; };
|
|
11 // { dg-message "satisfaction of .c2<T>. .with T = char." "" { target *-*-* } .-1 }
|
|
12 // { dg-message "in requirements with .T x. .with T = char." "" { target *-*-* } .-2 }
|
|
13 // { dg-message "required expression .* is invalid" "" { target *-*-* } .-3 }
|
|
14
|
|
15 template<typename T>
|
|
16 concept c3 = __is_same(T, const T) || __is_same(T, int);
|
|
17 // { dg-message "satisfaction of .c3<T>. .with T = char." "" { target *-*-* } .-1 }
|
|
18 // { dg-message "no operand of the disjunction is satisfied" "" { target *-*-* } .-2 }
|
|
19
|
|
20 template<typename T>
|
|
21 concept c4 = requires (T x) { requires c2<const T> || c2<volatile T>; };
|
|
22 // { dg-message "satisfaction of .c4<T>. .with T = char." "" { target *-*-* } .-1 }
|
|
23 // { dg-message "nested requirement" "" { target *-*-* } .-2 }
|
|
24
|
|
25 template<typename T>
|
|
26 concept c5 = requires (T x) { { &x } -> c1; };
|
|
27 // { dg-message "satisfaction of .c5<T>. .with T = char." "" { target *-*-* } .-1 }
|
|
28 // { dg-message "in requirements with .T x. .with T = char." "" { target *-*-* } .-2 }
|
|
29
|
|
30 template<typename T>
|
|
31 requires (c1<T> || c2<T>) || (c3<T> || c4<T>) || c5<T> // { dg-message "49: no operand" }
|
|
32 // { dg-message ".c1<T>. is unsatisfied because" "" { target *-*-* } .-1 }
|
|
33 // { dg-message ".c2<T>. is unsatisfied because" "" { target *-*-* } .-2 }
|
|
34 // { dg-message ".c3<T>. is unsatisfied because" "" { target *-*-* } .-3 }
|
|
35 // { dg-message ".c4<T>. is unsatisfied because" "" { target *-*-* } .-4 }
|
|
36 // { dg-message ".c5<T>. is unsatisfied because" "" { target *-*-* } .-5 }
|
|
37 void foo() { }
|
|
38
|
|
39 void
|
|
40 bar()
|
|
41 {
|
|
42 foo<char>(); // { dg-error "use of" }
|
|
43 }
|