summaryrefslogtreecommitdiff
path: root/test/SemaCXX/ambig-user-defined-conversions.cpp
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2009-10-14 18:03:49 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2009-10-14 18:03:49 +0000
commit4c8b24812ddcd1dedaca343a6d4e76f91f398981 (patch)
tree137ebebcae16fb0ce7ab4af456992bbd8d22fced /test/SemaCXX/ambig-user-defined-conversions.cpp
parent5362a71c02e7d448a8ce98cf00c47e353fba5d04 (diff)
Notes
Diffstat (limited to 'test/SemaCXX/ambig-user-defined-conversions.cpp')
-rw-r--r--test/SemaCXX/ambig-user-defined-conversions.cpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/SemaCXX/ambig-user-defined-conversions.cpp b/test/SemaCXX/ambig-user-defined-conversions.cpp
new file mode 100644
index 0000000000000..94598f0e8ef2f
--- /dev/null
+++ b/test/SemaCXX/ambig-user-defined-conversions.cpp
@@ -0,0 +1,52 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// Test1
+struct BASE {
+ operator int &(); // expected-note {{candidate function}}
+};
+struct BASE1 {
+ operator int &(); // expected-note {{candidate function}}
+};
+
+struct B : public BASE, BASE1 {
+
+};
+
+extern B f();
+
+B b1;
+void func(const int ci, const char cc); // expected-note {{candidate function}}
+void func(const char ci, const B b); // expected-note {{candidate function}}
+void func(const B b, const int ci); // expected-note {{candidate function}}
+
+const int Test1() {
+ func(b1, f()); // expected-error {{call to 'func' is ambiguous}}
+ return f(); // expected-error {{conversion from 'struct B' to 'int const' is ambiguous}}
+}
+
+
+// Test2
+struct E;
+struct A {
+ A (E&);
+};
+
+struct E {
+ operator A ();
+};
+
+struct C {
+ C (E&);
+};
+
+void f1(A); // expected-note {{candidate function}}
+void f1(C); // expected-note {{candidate function}}
+
+void Test2()
+{
+ E b;
+ f1(b); // expected-error {{call to 'f1' is ambiguous}}
+ // ambiguous because b -> C via constructor and
+ // b → A via constructor or conversion function.
+}
+