diff options
Diffstat (limited to 'test/SemaCXX')
-rw-r--r-- | test/SemaCXX/conditional-expr.cpp | 27 | ||||
-rw-r--r-- | test/SemaCXX/copy-initialization.cpp | 20 |
2 files changed, 47 insertions, 0 deletions
diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp index e2a966bd..49bcd99 100644 --- a/test/SemaCXX/conditional-expr.cpp +++ b/test/SemaCXX/conditional-expr.cpp @@ -213,3 +213,30 @@ namespace PR6595 { (void)(Cond? a : S); } } + +namespace PR6757 { + struct Foo1 { + Foo1(); + Foo1(const Foo1&); + }; + + struct Foo2 { }; + + struct Foo3 { + Foo3(); + Foo3(Foo3&); + }; + + struct Bar { + operator const Foo1&() const; + operator const Foo2&() const; + operator const Foo3&() const; + }; + + void f() { + (void)(true ? Bar() : Foo1()); // okay + (void)(true ? Bar() : Foo2()); // okay + // FIXME: Diagnostic below could be improved + (void)(true ? Bar() : Foo3()); // expected-error{{incompatible operand types ('PR6757::Bar' and 'PR6757::Foo3')}} + } +} diff --git a/test/SemaCXX/copy-initialization.cpp b/test/SemaCXX/copy-initialization.cpp index 3a63be0..e5b1fd7 100644 --- a/test/SemaCXX/copy-initialization.cpp +++ b/test/SemaCXX/copy-initialization.cpp @@ -21,3 +21,23 @@ struct foo { // PR3600 void test(const foo *P) { P->bar(); } // expected-error{{cannot initialize object parameter of type 'foo' with an expression of type 'foo const'}} + +namespace PR6757 { + struct Foo { + Foo(); + Foo(Foo&); + }; + + struct Bar { + operator const Foo&() const; + }; + + void f(Foo); // expected-note{{candidate function not viable: no known conversion from 'PR6757::Bar' to 'PR6757::Foo' for 1st argument}} + + // FIXME: This isn't really the right reason for the failure. We + // should fail after overload resolution. + void g(Foo foo) { + f(Bar()); // expected-error{{no matching function for call to 'f'}} + f(foo); + } +} |