1 // RUN: %clang_cc1 -std=c++2a -verify %s
3 template<typename T
, typename U
>
4 constexpr bool is_same_v
= false;
7 constexpr bool is_same_v
<T
, T
> = true;
11 void f1non_templ(int a
) requires
true; // expected-error{{non-templated function cannot have a requires clause}}
12 auto f2non_templ(int a
) -> bool requires
true; // expected-error{{non-templated function cannot have a requires clause}}
13 auto f3non_templ(int a
) -> bool (*)(int b
) requires
true; // expected-error{{non-templated function cannot have a requires clause}}
14 // expected-error@+1{{non-templated function cannot have a requires clause}}
15 auto f4_non_templ(int a
) requires
true -> bool; // expected-error{{trailing return type must appear before trailing requires clause}}
16 void (f7non_templ()) requires
true; // expected-error{{non-templated function cannot have a requires clause}}
17 // expected-error@+1{{non-templated function cannot have a requires clause}}
18 void (f8non_templ() requires
true); // expected-error{{trailing requires clause should be placed outside parentheses}}
19 // expected-error@+1{{non-templated function cannot have a requires clause}}
20 T xnon_templ requires
true;
21 // expected-error@+2 2{{non-templated function cannot have a requires clause}}
23 T m1 requires
true, m2 requires
true;
31 auto f2(int a
) -> bool
35 auto f3(int a
) -> bool (*)(int b
) requires
true; // OK
37 auto f4(int a
) requires
true -> bool; // expected-error{{trailing return type must appear before trailing requires clause}}
38 int f5(int a
) requires
; // expected-error{{expected expression}}
39 int f6(int a
) requires
{} // expected-error{{expected expression}}
41 void (f7()) requires
true;
43 void (f8() requires
true); // expected-error{{trailing requires clause should be placed outside parentheses}}
44 void (*(f9
requires (true)))(); // expected-error{{trailing requires clause should be placed outside parentheses}}
45 static_assert(is_same_v
<decltype(f9
), void (*)()>);
46 void (*pf
)() requires
true; // expected-error{{trailing requires clause can only be used when declaring a function}}
47 void g1(int (*dsdads
)() requires
false); // expected-error{{trailing requires clause can only be used when declaring a function}}
48 void g2(int (*(*dsdads
)())() requires
true); // expected-error{{trailing requires clause can only be used when declaring a function}}
49 void g3(int (*(*dsdads
)(int) requires
true)() ); // expected-error{{trailing requires clause should be placed outside parentheses}}
59 T m1 requires
true, m2 requires
true;
68 R(T
) -> R
<T
> requires
true; // expected-error{{deduction guide cannot have a requires clause}}