blob: 3b06119393d00bfa0b2c8ac35349c0c84e9d2781 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify %s
Douglas Gregor904eed32008-11-10 20:40:00 +00002int f(double);
3int f(int);
4
5int (*pfd)(double) = f; // selects f(double)
6int (*pfd2)(double) = &f; // selects f(double)
7int (*pfd3)(double) = ((&((f)))); // selects f(double)
8int (*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.
Eli Friedmana91eb542009-12-22 02:10:53 +000012int (*pfe)(...) = &f; // expected-error{{cannot initialize a variable of type 'int (*)(...)' with an rvalue of type '<overloaded function type>'}}
Douglas Gregor904eed32008-11-10 20:40:00 +000013int (&rfi)(int) = f; // selects f(int)
14int (&rfd)(double) = f; // selects f(double)
15
16void g(int (*fp)(int)); // expected-note{{note: candidate function}}
17void g(int (*fp)(float));
18void g(int (*fp)(double)); // expected-note{{note: candidate function}}
19
20int g1(int);
21int g1(char);
22
23int g2(int);
24int g2(double);
25
Douglas Gregord173b202009-09-14 22:02:01 +000026template<typename T> T g3(T);
27int g3(int);
28int g3(char);
29
Douglas Gregor904eed32008-11-10 20:40:00 +000030void g_test() {
31 g(g1);
32 g(g2); // expected-error{{call to 'g' is ambiguous; candidates are:}}
Douglas Gregord173b202009-09-14 22:02:01 +000033 g(g3);
34}
35
36template<typename T> T h1(T);
37template<typename R, typename A1> R h1(A1);
Douglas Gregor60d92312009-09-14 22:31:20 +000038int h1(char);
Douglas Gregord173b202009-09-14 22:02:01 +000039
Douglas Gregor60d92312009-09-14 22:31:20 +000040void ha(int (*fp)(int));
41void hb(int (*fp)(double));
Douglas Gregord173b202009-09-14 22:02:01 +000042
43void h_test() {
Douglas Gregor60d92312009-09-14 22:31:20 +000044 ha(h1);
45 hb(h1);
Douglas Gregor904eed32008-11-10 20:40:00 +000046}
Anders Carlsson6e8f5502009-10-07 22:26:29 +000047
48struct A { };
49void f(void (*)(A *));
50
51struct B
52{
53 void g() { f(d); }
54 void d(void *);
55 static void d(A *);
56};