1 // RUN: %clang_cc1 -std=c++20 -verify %s
4 concept c
= requires(T t
) { f(t
); }; // #CDEF
6 auto f(c
auto); // #FDEF
10 // expected-error@-1{{no matching function for call to 'f'}}
11 // expected-note@#FDEF{{constraints not satisfied}}
12 // expected-note@#FDEF{{because 'int' does not satisfy 'c'}}
13 // expected-note@#CDEF{{because 'f(t)' would be invalid: no matching function for call to 'f'}}
15 } // namespace GH53213
24 constexpr bool f(type
<T
>) {
29 concept matches
= f(type
<T
>());
33 template<typename U
> requires matches
<U
>
34 explicit constrained(U value
) {
38 bool f(constrained
const &) {
46 bool f(outer
const & x
) {
49 } // namespace GH45736
51 namespace DirectRecursiveCheck
{
53 concept NotInf
= true;
55 concept Inf
= requires(T
& v
){ // #INF_REQ
56 {begin(v
)}; // #INF_BEGIN_EXPR
59 void begin(NotInf
auto& v
){ } // #NOTINF_BEGIN
60 // This lookup should fail, since it results in a recursive check.
61 // However, this is a 'hard failure'(not a SFINAE failure or constraints
62 // violation), so it needs to cause the entire lookup to fail.
63 void begin(Inf
auto& v
){ } // #INF_BEGIN
69 auto it
= begin(rng
); // #BEGIN_CALL
70 // expected-error@#INF_BEGIN {{satisfaction of constraint 'Inf<Inf auto>' depends on itself}}
71 // expected-note@#INF_BEGIN {{while substituting template arguments into constraint expression here}}
72 // expected-note@#INF_BEGIN_EXPR {{while checking constraint satisfaction for template 'begin<DirectRecursiveCheck::my_range>' required here}}
73 // expected-note@#INF_BEGIN_EXPR {{while substituting deduced template arguments into function template 'begin'}}
74 // expected-note@#INF_BEGIN_EXPR {{in instantiation of requirement here}}
75 // expected-note@#INF_REQ {{while substituting template arguments into constraint expression here}}
76 // expected-note@#INF_BEGIN {{while checking the satisfaction of concept 'Inf<DirectRecursiveCheck::my_range>' requested here}}
77 // expected-note@#INF_BEGIN {{while substituting template arguments into constraint expression here}}
78 // expected-note@#BEGIN_CALL {{while checking constraint satisfaction for template 'begin<DirectRecursiveCheck::my_range>' required here}}
79 // expected-note@#BEGIN_CALL {{in instantiation of function template specialization}}
81 // Fallout of the failure is failed lookup, which is necessary to stop odd
83 // expected-error@#BEGIN_CALL {{no matching function for call to 'begin'}}
84 // expected-note@#NOTINF_BEGIN {{candidate function}}
85 // expected-note@#INF_BEGIN{{candidate template ignored: constraints not satisfied}}
87 } // namespace DirectRecursiveCheck
91 concept Numeric
= requires(T a
) { // #NUMERIC
96 friend void foo(Deferred
);
97 template <Numeric TO
> operator TO(); // #OP_TO
100 static_assert(Numeric
<Deferred
>); // #STATIC_ASSERT
101 // expected-error@#NUMERIC{{satisfaction of constraint 'requires (T a) { foo(a); }' depends on itself}}
102 // expected-note@#NUMERIC {{while substituting template arguments into constraint expression here}}
103 // expected-note@#OP_TO {{while checking the satisfaction of concept 'Numeric<GH50891::Deferred>' requested here}}
104 // expected-note@#OP_TO {{while substituting template arguments into constraint expression here}}
105 // expected-note@#FOO_CALL {{while checking constraint satisfaction for template}}
106 // expected-note@#FOO_CALL {{in instantiation of function template specialization}}
107 // expected-note@#FOO_CALL {{in instantiation of requirement here}}
108 // expected-note@#NUMERIC {{while substituting template arguments into constraint expression here}}
110 // expected-error@#STATIC_ASSERT {{static assertion failed}}
111 // expected-note@#STATIC_ASSERT{{while checking the satisfaction of concept 'Numeric<GH50891::Deferred>' requested here}}
112 // expected-note@#STATIC_ASSERT{{because substituted constraint expression is ill-formed: constraint depends on a previously diagnosed expression}}
114 } // namespace GH50891
118 // This should not diagnose, as it does not depend on itself.
125 requires requires
{ go(t
); }
132 { return End().endparens(t
); }
136 requires requires
{ go(t
); }
143 Size().sizeparens(i
);