1 // RUN: %clang_cc1 -std=c++20 -verify %s
2 // RUN: %clang_cc1 -std=c++2b -verify %s
3
4 namespace PR52905 {
5 template <class> concept C = true;
6
7 struct A {
8 int begin();
9 int begin() const;
10 };
11
12 template <class T>
13 concept Beginable = requires (T t) {
14 { t.begin } -> C;
15 // expected-note@-1 {{because 't.begin' would be invalid: reference to non-static member function must be called}}
16 };
17
18 static_assert(Beginable<A>); // expected-error {{static assertion failed}}
19 // expected-note@-1 {{does not satisfy 'Beginable'}}
20 } // namespace PR52905
21
22 namespace PR52909a {
23
24 template<class> constexpr bool B = true;
25 template<class T> concept True = B<T>;
26
27 template <class T>
foo(T t)28 int foo(T t) requires requires { // expected-note {{candidate template ignored: constraints not satisfied}}
29 {t.begin} -> True; // expected-note {{because 't.begin' would be invalid: reference to non-static member function must be called}}
30 }
31 {}
32
33 struct A { int begin(); };
34 auto x = foo(A()); // expected-error {{no matching function for call to 'foo'}}
35
36 } // namespace PR52909a
37
38 namespace PR52909b {
39
40 template<class> concept True = true;
41
42 template<class T> concept C = requires {
43 { T::begin } -> True; // expected-note {{because 'T::begin' would be invalid: reference to overloaded function could not be resolved}}
44 };
45
46 struct A {
47 static void begin(int);
48 static void begin(double);
49 };
50
51 static_assert(C<A>); // expected-error {{static assertion failed}}
52 // expected-note@-1 {{because 'PR52909b::A' does not satisfy 'C'}}
53
54 } // namespace PR52909b
55
56 namespace PR53075 {
57 template<class> concept True = true;
58
59 template<class T> concept C = requires {
60 { &T::f } -> True; // expected-note {{because '&T::f' would be invalid: reference to overloaded function could not be resolved}}
61 };
62
63 struct S {
64 int *f();
65 int *f() const;
66 };
67
68 static_assert(C<S>); // expected-error {{static assertion failed}}
69 // expected-note@-1 {{because 'PR53075::S' does not satisfy 'C'}}
70
71 } // namespace PR53075
72