diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/SemaCXX/aggregate-initialization.cpp | 4 | ||||
-rw-r--r-- | test/SemaCXX/conditional-expr.cpp | 5 | ||||
-rw-r--r-- | test/SemaCXX/conversion-function.cpp | 28 | ||||
-rw-r--r-- | test/SemaCXX/copy-initialization.cpp | 8 | ||||
-rw-r--r-- | test/SemaCXX/user-defined-conversions.cpp | 15 | ||||
-rw-r--r-- | test/SemaTemplate/constructor-template.cpp | 15 |
6 files changed, 64 insertions, 11 deletions
diff --git a/test/SemaCXX/aggregate-initialization.cpp b/test/SemaCXX/aggregate-initialization.cpp index 708a8f256a..81a0e6f744 100644 --- a/test/SemaCXX/aggregate-initialization.cpp +++ b/test/SemaCXX/aggregate-initialization.cpp @@ -60,10 +60,10 @@ struct C { void f() { A as1[1] = { }; - A as2[1] = { 1 }; // expected-error {{copying array element of type 'A' invokes deleted copy constructor}} + A as2[1] = { 1 }; // expected-error {{copying array element of type 'A' invokes deleted constructor}} B b1 = { }; - B b2 = { 1 }; // expected-error {{copying member subobject of type 'A' invokes deleted copy constructor}} + B b2 = { 1 }; // expected-error {{copying member subobject of type 'A' invokes deleted constructor}} C c1 = { 1 }; } diff --git a/test/SemaCXX/conditional-expr.cpp b/test/SemaCXX/conditional-expr.cpp index cb78a2e65f..aa41323239 100644 --- a/test/SemaCXX/conditional-expr.cpp +++ b/test/SemaCXX/conditional-expr.cpp @@ -224,7 +224,7 @@ namespace PR6757 { struct Foo3 { Foo3(); - Foo3(Foo3&); + Foo3(Foo3&); // expected-note{{would lose const qualifier}} }; struct Bar { @@ -236,7 +236,6 @@ namespace PR6757 { 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')}} + (void)(true ? Bar() : Foo3()); // expected-error{{no viable constructor copying temporary}} } } diff --git a/test/SemaCXX/conversion-function.cpp b/test/SemaCXX/conversion-function.cpp index 972409ca5a..dfc0650641 100644 --- a/test/SemaCXX/conversion-function.cpp +++ b/test/SemaCXX/conversion-function.cpp @@ -129,7 +129,7 @@ private: }; A1 f() { - return "Hello"; // expected-error{{invokes deleted copy constructor}} + return "Hello"; // expected-error{{invokes deleted constructor}} } namespace source_locations { @@ -176,3 +176,29 @@ namespace crazy_declarators { *operator int(); // expected-error {{must use a typedef to declare a conversion to 'int *'}} }; } + +namespace smart_ptr { + class Y { + class YRef { }; + + Y(Y&); + + public: + Y(); + Y(YRef); + + operator YRef(); // expected-note{{candidate function}} + }; + + struct X { // expected-note{{candidate constructor (the implicit copy constructor) not}} + explicit X(Y); + }; + + Y make_Y(); + + X f() { + X x = make_Y(); // expected-error{{no viable conversion from 'smart_ptr::Y' to 'smart_ptr::X'}} + X x2(make_Y()); + return X(Y()); + } +} diff --git a/test/SemaCXX/copy-initialization.cpp b/test/SemaCXX/copy-initialization.cpp index e5b1fd766b..ea67e6ffe2 100644 --- a/test/SemaCXX/copy-initialization.cpp +++ b/test/SemaCXX/copy-initialization.cpp @@ -25,19 +25,17 @@ void test(const foo *P) { P->bar(); } // expected-error{{cannot initialize objec namespace PR6757 { struct Foo { Foo(); - Foo(Foo&); + Foo(Foo&); // expected-note{{candidate constructor not viable}} }; 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}} + void f(Foo); - // 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(Bar()); // expected-error{{no viable constructor copying parameter of type 'PR6757::Foo const'}} f(foo); } } diff --git a/test/SemaCXX/user-defined-conversions.cpp b/test/SemaCXX/user-defined-conversions.cpp index 4367f4b8a3..5de7f44be9 100644 --- a/test/SemaCXX/user-defined-conversions.cpp +++ b/test/SemaCXX/user-defined-conversions.cpp @@ -67,3 +67,18 @@ void test_conversion(ConvertibleToBase ctb, ConvertibleToDerived ctd, Base b4(ctd); Base b5 = ctfd; } + +struct X1 { + X1(X1&); // expected-note{{candidate constructor not viable: no known conversion from 'X1' to 'X1 &' for 1st argument}} +}; + +struct X2 { + operator X1(); +}; + +int &f(X1); +float &f(...); + +void g(X2 b) { + int &ir = f(b); // expected-error{{no viable constructor copying parameter of type 'X1'}} +} diff --git a/test/SemaTemplate/constructor-template.cpp b/test/SemaTemplate/constructor-template.cpp index 82c2aa4cc3..b6ca72e9e1 100644 --- a/test/SemaTemplate/constructor-template.cpp +++ b/test/SemaTemplate/constructor-template.cpp @@ -94,3 +94,18 @@ void default_ctor_inst() { } template void default_ctor_inst<int>(); + +template<typename T> +struct X5 { + X5(); + X5(const T &); +}; + +struct X6 { + template<typename T> X6(T); +}; + +void test_X5_X6() { + X5<X6> tf; + X5<X6> tf2(tf); +} |