[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaTemplate / pr52909.cpp
blobccde5903342a665b4d4724e722b5832cd2cf86cb
1 // RUN: %clang_cc1 -std=c++20 -verify %s
2 // RUN: %clang_cc1 -std=c++2b -verify %s
4 namespace PR52905 {
5 template <class> concept C = true;
7 struct A {
8 int begin();
9 int begin() const;
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}}
18 static_assert(Beginable<A>); // expected-error {{static assertion failed}}
19 // expected-note@-1 {{does not satisfy 'Beginable'}}
20 } // namespace PR52905
22 namespace PR52909a {
24 template<class> constexpr bool B = true;
25 template<class T> concept True = B<T>;
27 template <class 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}}
33 struct A { int begin(); };
34 auto x = foo(A()); // expected-error {{no matching function for call to 'foo'}}
36 } // namespace PR52909a
38 namespace PR52909b {
40 template<class> concept True = true;
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}}
46 struct A {
47 static void begin(int);
48 static void begin(double);
51 static_assert(C<A>); // expected-error {{static assertion failed}}
52 // expected-note@-1 {{because 'A' does not satisfy 'C'}}
54 } // namespace PR52909b
56 namespace PR53075 {
57 template<class> concept True = true;
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}}
63 struct S {
64 int *f();
65 int *f() const;
68 static_assert(C<S>); // expected-error {{static assertion failed}}
69 // expected-note@-1 {{because 'S' does not satisfy 'C'}}
71 } // namespace PR53075