[libc++][NFC] Remove trailing whitespace from release notes
[llvm-project.git] / clang / test / CXX / expr / expr.unary / expr.unary.op / p4.cpp
blobe49f396143ad65208c923a584dba85afcc84c5d1
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
3 namespace test0 {
4 struct A {
5 void foo(void (A::*)(int)); // expected-note {{passing argument to parameter here}}
6 template<typename T> void g(T);
8 void test() {
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.
15 namespace test1 {
16 struct A {
17 static void f(void (A::*)());
18 static void f(void (*)(int));
19 void g();
20 static void g(int);
22 void test() {
23 f(&g);
28 namespace test2 {
29 struct A {
30 static int foo(short);
31 static int foo(float);
32 int foo(int);
33 int foo(double);
35 void test();
38 void A::test() {
39 // FIXME: The error message in this case is less than clear, we can do
40 // better.
41 int (A::*ptr)(int) = &(A::foo); // expected-error {{cannot create a non-constant pointer to member function}}
45 namespace GH40906 {
46 struct S {
47 int x;
48 void func();
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}}
61 struct A { int x;};
63 char q(int *);
64 short q(int A::*);
66 template <typename T>
67 constexpr int f(char (*)[sizeof(q(&T::x))]) { return 1; }
69 template <typename T>
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);