diff options
author | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
---|---|---|
committer | Carlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au> | 2012-10-15 17:10:06 +1100 |
commit | be1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch) | |
tree | 1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaCXX/ambig-user-defined-conversions.cpp | |
parent | c4626a62754862d20b41e8a46a3574264ea80e6d (diff) | |
parent | f1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff) |
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaCXX/ambig-user-defined-conversions.cpp')
-rw-r--r-- | clang/test/SemaCXX/ambig-user-defined-conversions.cpp | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/ambig-user-defined-conversions.cpp b/clang/test/SemaCXX/ambig-user-defined-conversions.cpp new file mode 100644 index 0000000..1a3c102 --- /dev/null +++ b/clang/test/SemaCXX/ambig-user-defined-conversions.cpp @@ -0,0 +1,67 @@ +// RUN: %clang_cc1 -fsyntax-only -verify %s + +namespace test0 { + 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 'test0::B' to 'const int' is ambiguous}} + } + + // This used to crash when comparing the two operands. + void func2(const char cc); // expected-note {{candidate function}} + void func2(const int ci); // expected-note {{candidate function}} + void Test2() { + func2(b1); // expected-error {{call to 'func2' is ambiguous}} + } +} + +namespace test1 { + 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. + } +} + +namespace rdar8876150 { + struct A { operator bool(); }; + struct B : A { }; + struct C : A { }; + struct D : B, C { }; + + bool f(D d) { return !d; } // expected-error{{ambiguous conversion from derived class 'rdar8876150::D' to base class 'rdar8876150::A':}} +} |