[Flang] remove whole-archive option for AIX linker (#76039)
[llvm-project.git] / clang / test / CXX / expr / expr.prim / expr.prim.req / requires-expr.cpp
blob90a38292d15d3586bb5c1848de606265fb17df20
1 // RUN: %clang_cc1 -std=c++2a -x c++ %s -verify
3 using A = int;
5 template<typename T, typename U>
6 constexpr bool is_same_v = false;
8 template<typename T>
9 constexpr bool is_same_v<T, T> = true;
11 template<typename T, typename U>
12 concept same_as = is_same_v<T, U>;
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; })>);
18 // Check that requires expr is an unevaluated context.
19 struct Y {
20 int i;
21 static constexpr bool r = requires { i; };
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;
31 struct r1 { };
33 using r1i = r1<int>;
34 // expected-error@-1 {{constraints not satisfied for class template 'r1' [with T = int]}}
36 template<typename T> requires requires (T t) {
37 requires requires {
38 requires false; // expected-note{{because 'false' evaluated to false}}
41 struct r2 { };
43 using r2i = r2<int>;
44 // expected-error@-1 {{constraints not satisfied for class template 'r2' [with T = int]}}
46 template<typename T> requires requires (T t) {
47 requires requires {
48 requires true;
50 requires true;
51 requires requires {
52 requires false; // expected-note{{because 'false' evaluated to false}}
55 struct r3 { };
57 using r3i = r3<int>;
58 // expected-error@-1 {{constraints not satisfied for class template 'r3' [with T = int]}}
60 template<typename T>
61 struct S { static const int s = T::value; };
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 { };
67 using r4i = r4<int>;
68 // expected-error@-1 {{constraints not satisfied for class template 'r4' [with T = int]}}