2009-03-24 10:24:46 +08:00
|
|
|
// RUN: clang-cc -fsyntax-only -verify %s
|
2008-11-11 04:40:00 +08:00
|
|
|
int f(double);
|
|
|
|
int f(int);
|
|
|
|
|
|
|
|
int (*pfd)(double) = f; // selects f(double)
|
|
|
|
int (*pfd2)(double) = &f; // selects f(double)
|
|
|
|
int (*pfd3)(double) = ((&((f)))); // selects f(double)
|
|
|
|
int (*pfi)(int) = &f; // selects f(int)
|
|
|
|
// FIXME: This error message is not very good. We need to keep better
|
|
|
|
// track of what went wrong when the implicit conversion failed to
|
|
|
|
// give a better error message here.
|
|
|
|
int (*pfe)(...) = &f; // expected-error{{incompatible type initializing '<overloaded function type>', expected 'int (*)(...)'}}
|
|
|
|
int (&rfi)(int) = f; // selects f(int)
|
|
|
|
int (&rfd)(double) = f; // selects f(double)
|
|
|
|
|
|
|
|
void g(int (*fp)(int)); // expected-note{{note: candidate function}}
|
|
|
|
void g(int (*fp)(float));
|
|
|
|
void g(int (*fp)(double)); // expected-note{{note: candidate function}}
|
|
|
|
|
|
|
|
int g1(int);
|
|
|
|
int g1(char);
|
|
|
|
|
|
|
|
int g2(int);
|
|
|
|
int g2(double);
|
|
|
|
|
2009-09-15 06:02:01 +08:00
|
|
|
template<typename T> T g3(T);
|
|
|
|
int g3(int);
|
|
|
|
int g3(char);
|
|
|
|
|
2008-11-11 04:40:00 +08:00
|
|
|
void g_test() {
|
|
|
|
g(g1);
|
|
|
|
g(g2); // expected-error{{call to 'g' is ambiguous; candidates are:}}
|
2009-09-15 06:02:01 +08:00
|
|
|
g(g3);
|
|
|
|
}
|
|
|
|
|
|
|
|
template<typename T> T h1(T);
|
|
|
|
template<typename R, typename A1> R h1(A1);
|
2009-09-15 06:31:20 +08:00
|
|
|
int h1(char);
|
2009-09-15 06:02:01 +08:00
|
|
|
|
2009-09-15 06:31:20 +08:00
|
|
|
void ha(int (*fp)(int));
|
|
|
|
void hb(int (*fp)(double));
|
2009-09-15 06:02:01 +08:00
|
|
|
|
|
|
|
void h_test() {
|
2009-09-15 06:31:20 +08:00
|
|
|
ha(h1);
|
|
|
|
hb(h1);
|
2008-11-11 04:40:00 +08:00
|
|
|
}
|