p4.cpp revision 651f13cea278ec967336033dd032faef0e9fc2ec
1// RUN: %clang_cc1 -fsyntax-only -verify %s
2
3// rdar://problem/8347416
4namespace test0 {
5  struct A {
6    void foo(void (A::*)(int)); // expected-note {{passing argument to parameter here}}
7    template<typename T> void g(T);
8
9    void test() {
10      foo(&g<int>); // expected-error-re {{can't form member pointer of type 'void (test0::A::*)(int){{( __attribute__\(\(thiscall\)\))?}}' without '&' and class name}}
11    }
12  };
13}
14
15// This should succeed.
16namespace test1 {
17  struct A {
18    static void f(void (A::*)());
19    static void f(void (*)(int));
20    void g();
21    static void g(int);
22
23    void test() {
24      f(&g);
25    }
26  };
27}
28
29// Also rdar://problem/8347416
30namespace test2 {
31  struct A {
32    static int foo(short);
33    static int foo(float);
34    int foo(int);
35    int foo(double);
36
37    void test();
38  };
39
40  void A::test() {
41    // FIXME: The error message in this case is less than clear, we can do
42    // better.
43    int (A::*ptr)(int) = &(A::foo); // expected-error {{cannot create a non-constant pointer to member function}}
44  }
45}
46