1 // RUN: %clang_cc1 -std=c++2a -x c++ %s -verify 2 3 using A = int; 4 5 template<typename T, typename U> 6 constexpr bool is_same_v = false; 7 8 template<typename T> 9 constexpr bool is_same_v<T, T> = true; 10 11 template<typename T, typename U> 12 concept same_as = is_same_v<T, U>; 13 14 static_assert(requires { requires true; 0; typename A; 15 { 0 } -> same_as<int>; }); 16 static_assert(is_same_v<bool, decltype(requires { requires false; })>); 17 18 // Check that requires expr is an unevaluated context. 19 struct Y { 20 int i; 21 static constexpr bool r = requires { i; }; 22 }; 23 24 template<typename T> requires requires (T t) { 25 requires false; // expected-note{{because 'false' evaluated to false}} 26 requires false; 27 requires requires { 28 requires false; 29 }; 30 } 31 struct r1 { }; 32 33 using r1i = r1<int>; 34 // expected-error@-1 {{constraints not satisfied for class template 'r1' [with T = int]}} 35 36 template<typename T> requires requires (T t) { 37 requires requires { 38 requires false; // expected-note{{because 'false' evaluated to false}} 39 }; 40 } 41 struct r2 { }; 42 43 using r2i = r2<int>; 44 // expected-error@-1 {{constraints not satisfied for class template 'r2' [with T = int]}} 45 46 template<typename T> requires requires (T t) { 47 requires requires { 48 requires true; 49 }; 50 requires true; 51 requires requires { 52 requires false; // expected-note{{because 'false' evaluated to false}} 53 }; 54 } 55 struct r3 { }; 56 57 using r3i = r3<int>; 58 // expected-error@-1 {{constraints not satisfied for class template 'r3' [with T = int]}} 59 60 template<typename T> 61 struct S { static const int s = T::value; }; 62 63 template<typename T> requires requires { T::value; S<T>::s; } 64 // expected-note@-1 {{because 'T::value' would be invalid: type 'int' cannot be used prior to '::' because it has no members}} 65 struct r4 { }; 66 67 using r4i = r4<int>; 68 // expected-error@-1 {{constraints not satisfied for class template 'r4' [with T = int]}}