]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/SemaCXX/addr-of-overloaded-function.cpp
Update clang to r100181.
[FreeBSD/FreeBSD.git] / test / SemaCXX / addr-of-overloaded-function.cpp
1 // RUN: %clang_cc1 -fsyntax-only -verify %s 
2 int f(double);
3 int f(int);
4
5 int (*pfd)(double) = f; // selects f(double)
6 int (*pfd2)(double) = &f; // selects f(double)
7 int (*pfd3)(double) = ((&((f)))); // selects f(double)
8 int (*pfi)(int) = &f;    // selects f(int)
9 // FIXME: This error message is not very good. We need to keep better
10 // track of what went wrong when the implicit conversion failed to
11 // give a better error message here.
12 int (*pfe)(...) = &f;    // expected-error{{cannot initialize a variable of type 'int (*)(...)' with an rvalue of type '<overloaded function type>'}}
13 int (&rfi)(int) = f;     // selects f(int)
14 int (&rfd)(double) = f;  // selects f(double)
15
16 void g(int (*fp)(int));   // expected-note{{note: candidate function}}
17 void g(int (*fp)(float));
18 void g(int (*fp)(double)); // expected-note{{note: candidate function}}
19
20 int g1(int);
21 int g1(char);
22
23 int g2(int);
24 int g2(double);
25
26 template<typename T> T g3(T);
27 int g3(int);
28 int g3(char);
29
30 void g_test() {
31   g(g1);
32   g(g2); // expected-error{{call to 'g' is ambiguous; candidates are:}}
33   g(g3);
34 }
35
36 template<typename T> T h1(T);
37 template<typename R, typename A1> R h1(A1);
38 int h1(char);
39
40 void ha(int (*fp)(int));
41 void hb(int (*fp)(double));
42
43 void h_test() {
44   ha(h1);
45   hb(h1);
46 }
47
48 struct A { };
49 void f(void (*)(A *));
50
51 struct B
52 {
53   void g() { f(d); }
54   void d(void *);
55   static void d(A *);
56 };