summaryrefslogtreecommitdiff
path: root/test/SemaCXX/addr-of-overloaded-function.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaCXX/addr-of-overloaded-function.cpp')
-rw-r--r--test/SemaCXX/addr-of-overloaded-function.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/SemaCXX/addr-of-overloaded-function.cpp b/test/SemaCXX/addr-of-overloaded-function.cpp
new file mode 100644
index 000000000000..9c9f0e19ef3c
--- /dev/null
+++ b/test/SemaCXX/addr-of-overloaded-function.cpp
@@ -0,0 +1,29 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+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);
+
+void g_test() {
+ g(g1);
+ g(g2); // expected-error{{call to 'g' is ambiguous; candidates are:}}
+}