1 // RUN: %clang_cc1 -fsyntax-only -verify %s
5 void foo(void (A::*)(int)); // expected-note {{passing argument to parameter here}}
6 template<typename T
> void g(T
);
9 foo(&g
<int>); // expected-error-re {{cannot form member pointer of type 'void (A::*)(int){{( __attribute__\(\(thiscall\)\))?}}' without '&' and class name}}
14 // This should succeed.
17 static void f(void (A::*)());
18 static void f(void (*)(int));
30 static int foo(short);
31 static int foo(float);
39 // FIXME: The error message in this case is less than clear, we can do
41 int (A::*ptr
)(int) = &(A::foo
); // expected-error {{cannot create a non-constant pointer to member function}}
49 static_assert(__is_same_as(decltype((S::x
)), int&), "");
50 static_assert(__is_same_as(decltype(&(S::x
)), int*), "");
52 // FIXME: provide better error messages
53 static_assert(__is_same_as(decltype((S::func
)), int&), ""); // expected-error {{call to non-static member function without an object argument}}
54 static_assert(__is_same_as(decltype(&(S::func
)), int*), ""); // expected-error {{call to non-static member function without an object argument}}
56 static_assert(__is_same_as(decltype((S::x
)), int&), "");
57 static_assert(__is_same_as(decltype(&(S::x
)), int*), "");
58 static_assert(__is_same_as(decltype((S::func
)), int&), ""); // expected-error {{call to non-static member function without an object argument}}
59 static_assert(__is_same_as(decltype(&(S::func
)), int*), ""); // expected-error {{call to non-static member function without an object argument}}
67 constexpr int f(char (*)[sizeof(q(&T::x
))]) { return 1; }
70 constexpr int f(char (*)[sizeof(q(&(T::x
)))]) { return 2; }
72 constexpr int g(char (*p
)[sizeof(char)] = 0) { return f
<A
>(p
); }
73 constexpr int h(char (*p
)[sizeof(short)] = 0) { return f
<A
>(p
); }
75 static_assert(g() == 2);
76 static_assert(h() == 1);