1 // RUN: %clang_cc1 -std=c++20 -x c++ -Wno-constant-logical-operand -verify %s
3 template<typename T
> concept C
=
4 sizeof(T
) == 4 && !true; // requires atomic constraints sizeof(T) == 4 and !true
6 template<typename T
> concept C2
= sizeof(T
); // expected-error{{atomic constraint must be of type 'bool' (found }}
8 template<typename T
> struct S
{
9 constexpr operator bool() const { return true; }
12 // expected-error@+3{{atomic constraint must be of type 'bool' (found 'S<int>')}}
13 // expected-note@#FINST{{while checking constraint satisfaction}}
14 // expected-note@#FINST{{in instantiation of function template specialization}}
15 template<typename T
> requires (S
<T
>{})
19 // Ensure this applies to operator && as well.
20 // expected-error@+3{{atomic constraint must be of type 'bool' (found 'S<int>')}}
21 // expected-note@#F2INST{{while checking constraint satisfaction}}
22 // expected-note@#F2INST{{in instantiation of function template specialization}}
23 template<typename T
> requires (S
<T
>{} && true)
27 template<typename T
> requires requires
{
29 // expected-error@-1{{atomic constraint must be of type 'bool' (found 'S<int>')}}
30 // expected-note@-2{{while checking the satisfaction}}
31 // expected-note@-3{{in instantiation of requirement}}
32 // expected-note@-4{{while checking the satisfaction}}
33 // expected-note@-6{{while substituting template arguments}}
34 // expected-note@#F3INST{{while checking constraint satisfaction}}
35 // expected-note@#F3INST{{in instantiation of function template specialization}}
41 // Doesn't diagnose, since this is no longer a compound requirement.
42 template<typename T
> requires (bool(1 && 2))
54 auto Nullptr
= nullptr;
56 template<typename T
> concept NullTy
= Nullptr
<T
>;
57 // expected-error@-1{{atomic constraint must be of type 'bool' (found }}
58 // expected-note@+1{{while checking the satisfaction}}
59 static_assert(NullTy
<int>);
64 template<typename T
> concept StructTy
= Struct
<T
>;
65 // expected-error@-1{{atomic constraint must be of type 'bool' (found 'S<int>')}}
66 // expected-note@+1{{while checking the satisfaction}}
67 static_assert(StructTy
<int>);