diff options
author | Douglas Gregor <dgregor@apple.com> | 2012-02-15 19:33:52 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2012-02-15 19:33:52 +0000 |
commit | e4e68d45f89ff4899d30cbd196603d09b7fbc150 (patch) | |
tree | 9dfe6c0e1b10bee53c490d4d5052c85078c2ddf9 /test/CXX/special | |
parent | b622959527c07cc6b68739eac1412f75f0ca77fa (diff) |
When overload resolution picks an implicitly-deleted special member
function, provide a specialized diagnostic that indicates the kind of
special member function (default constructor, copy assignment
operator, etc.) and that it was implicitly deleted. Add a hook where
we can provide more detailed information later.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150611 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/special')
-rw-r--r-- | test/CXX/special/class.copy/implicit-move.cpp | 10 | ||||
-rw-r--r-- | test/CXX/special/class.copy/p11.0x.copy.cpp | 14 | ||||
-rw-r--r-- | test/CXX/special/class.ctor/p5-0x.cpp | 57 |
3 files changed, 42 insertions, 39 deletions
diff --git a/test/CXX/special/class.copy/implicit-move.cpp b/test/CXX/special/class.copy/implicit-move.cpp index 74f7eee9ee..cc39af97ae 100644 --- a/test/CXX/special/class.copy/implicit-move.cpp +++ b/test/CXX/special/class.copy/implicit-move.cpp @@ -54,7 +54,7 @@ void test_basic_exclusion() { static_assert(noexcept(HasMoveConstructor((HasMoveConstructor()))), ""); HasMoveConstructor hmc; - hmc = HasMoveConstructor(); // expected-error {{selected deleted operator}} + hmc = HasMoveConstructor(); // expected-error {{selected implicitly-deleted copy assignment}} (HasMoveAssignment(HasMoveAssignment())); // expected-error {{uses deleted function}} HasMoveAssignment hma; @@ -87,8 +87,8 @@ private: ~PrivateDestructor() noexcept; }; -struct InheritsPrivateDestructor : PrivateDestructor {}; // expected-note {{explicitly marked deleted}} -struct ContainsPrivateDestructor { // expected-note {{explicitly marked deleted}} +struct InheritsPrivateDestructor : PrivateDestructor {}; // expected-note{{defined here}} +struct ContainsPrivateDestructor { // expected-note{{defined here}} PrivateDestructor pd; }; @@ -131,8 +131,8 @@ void test_deletion_exclusion() { ContainsPrivateMove cpm; static_assert(!noexcept(cpm = ContainsPrivateMove()), ""); - (InheritsPrivateDestructor(InheritsPrivateDestructor())); // expected-error {{call to deleted constructor}} - (ContainsPrivateDestructor(ContainsPrivateDestructor())); // expected-error {{call to deleted constructor}} + (InheritsPrivateDestructor(InheritsPrivateDestructor())); // expected-error {{call to implicitly-deleted default constructor}} + (ContainsPrivateDestructor(ContainsPrivateDestructor())); // expected-error {{call to implicitly-deleted default constructor}} static_assert(!noexcept(InheritsNonTrivialCopyOnly(InheritsNonTrivialCopyOnly())), ""); static_assert(!noexcept(ContainsNonTrivialCopyOnly(ContainsNonTrivialCopyOnly())), ""); diff --git a/test/CXX/special/class.copy/p11.0x.copy.cpp b/test/CXX/special/class.copy/p11.0x.copy.cpp index 752872adb9..65fd985924 100644 --- a/test/CXX/special/class.copy/p11.0x.copy.cpp +++ b/test/CXX/special/class.copy/p11.0x.copy.cpp @@ -9,7 +9,7 @@ union DeletedNTVariant { // expected-note{{here}} DeletedNTVariant(); }; DeletedNTVariant DVa; -DeletedNTVariant DVb(DVa); // expected-error{{call to deleted constructor}} +DeletedNTVariant DVb(DVa); // expected-error{{call to implicitly-deleted copy constructor}} struct DeletedNTVariant2 { // expected-note{{here}} union { @@ -18,7 +18,7 @@ struct DeletedNTVariant2 { // expected-note{{here}} DeletedNTVariant2(); }; DeletedNTVariant2 DV2a; -DeletedNTVariant2 DV2b(DV2a); // expected-error{{call to deleted constructor}} +DeletedNTVariant2 DV2b(DV2a); // expected-error{{call to implicitly-deleted copy constructor}} struct NoAccess { NoAccess() = default; @@ -32,7 +32,7 @@ struct HasNoAccess { // expected-note{{here}} NoAccess NA; }; HasNoAccess HNAa; -HasNoAccess HNAb(HNAa); // expected-error{{call to deleted constructor}} +HasNoAccess HNAb(HNAa); // expected-error{{call to implicitly-deleted copy constructor}} struct HasAccess { NoAccess NA; @@ -55,13 +55,13 @@ struct IsAmbiguous { // expected-note{{here}} IsAmbiguous(); }; IsAmbiguous IAa; -IsAmbiguous IAb(IAa); // expected-error{{call to deleted constructor}} +IsAmbiguous IAb(IAa); // expected-error{{call to implicitly-deleted copy constructor}} struct Deleted { // expected-note{{here}} IsAmbiguous IA; }; Deleted Da; -Deleted Db(Da); // expected-error{{call to deleted constructor}} +Deleted Db(Da); // expected-error{{call to implicitly-deleted copy constructor}} struct NoAccessDtor { private: @@ -75,7 +75,7 @@ struct HasNoAccessDtor { // expected-note{{here}} ~HasNoAccessDtor(); }; HasNoAccessDtor HNADa; -HasNoAccessDtor HNADb(HNADa); // expected-error{{call to deleted constructor}} +HasNoAccessDtor HNADb(HNADa); // expected-error{{call to implicitly-deleted copy constructor}} struct HasAccessDtor { NoAccessDtor NAD; @@ -87,4 +87,4 @@ struct RValue { // expected-note{{here}} int && ri = 1; }; RValue RVa; -RValue RVb(RVa); // expected-error{{call to deleted constructor}} +RValue RVb(RVa); // expected-error{{call to implicitly-deleted copy constructor}} diff --git a/test/CXX/special/class.ctor/p5-0x.cpp b/test/CXX/special/class.ctor/p5-0x.cpp index 00c25e8e3a..b2fa0cf298 100644 --- a/test/CXX/special/class.ctor/p5-0x.cpp +++ b/test/CXX/special/class.ctor/p5-0x.cpp @@ -21,19 +21,22 @@ int n; // - X is a union-like class that has a variant member with a non-trivial // default constructor, -union Deleted1a { UserProvidedDefCtor u; }; // expected-note {{deleted here}} -Deleted1a d1a; // expected-error {{deleted constructor}} +union Deleted1a { UserProvidedDefCtor u; }; // expected-note {{defined here}} +Deleted1a d1a; // expected-error {{implicitly-deleted default constructor}} union NotDeleted1a { DefaultedDefCtor1 nu; }; NotDeleted1a nd1a; // FIXME: clang implements the pre-FDIS rule, under which DefaultedDefCtor2's // default constructor is non-trivial. -union NotDeleted1b { DefaultedDefCtor2 nu; }; // unexpected-note {{deleted here}} -NotDeleted1b nd1b; // unexpected-error {{deleted constructor}} +union NotDeleted1b { DefaultedDefCtor2 nu; }; // unexpected-note {{defined here}} +NotDeleted1b nd1b; // unexpected-error {{implicitly-deleted default constructor}} // - any non-static data member with no brace-or-equal-initializer is of // reference type, -class Deleted2a { Deleted2a() = default; int &a; }; // expected-note {{deleted here}} -Deleted2a d2a; // expected-error {{deleted constructor}} +class Deleted2a { // expected-note {{defined here}} + Deleted2a() = default; // expected-note {{declared here}} + int &a; +}; +Deleted2a d2a; // expected-error {{implicitly-deleted default constructor}} class NotDeleted2a { int &a = n; }; NotDeleted2a nd2a; class NotDeleted2b { int &a = error; }; // expected-error {{undeclared identifier}} @@ -45,11 +48,11 @@ NotDeleted2b nd2b; class Deleted3a { const int a; }; // expected-note {{here}} \ expected-warning {{does not declare any constructor}} \ expected-note {{will never be initialized}} -Deleted3a d3a; // expected-error {{deleted constructor}} +Deleted3a d3a; // expected-error {{implicitly-deleted default constructor}} class Deleted3b { const DefaultedDefCtor1 a[42]; }; // expected-note {{here}} -Deleted3b d3b; // expected-error {{deleted constructor}} -class Deleted3c { const DefaultedDefCtor2 a; }; // expected-note {{deleted}} -Deleted3c d3c; // expected-error {{deleted constructor}} +Deleted3b d3b; // expected-error {{implicitly-deleted default constructor}} +class Deleted3c { const DefaultedDefCtor2 a; }; // expected-note {{defined here}} +Deleted3c d3c; // expected-error {{implicitly-deleted default constructor}} class NotDeleted3a { const int a = 0; }; NotDeleted3a nd3a; class NotDeleted3b { const DefaultedDefCtor1 a[42] = {}; }; @@ -60,23 +63,23 @@ union NotDeleted3d { const int a; int b; }; NotDeleted3d nd3d; // FIXME: this class should not have a deleted default constructor. union NotDeleted3e { const DefaultedDefCtor1 a[42]; int b; }; // unexpected-note {{here}} -NotDeleted3e nd3e; // unexpected-error {{deleted constructor}} +NotDeleted3e nd3e; // unexpected-error {{implicitly-deleted default constructor}} // FIXME: clang implements the pre-FDIS rule, under which DefaultedDefCtor2 is // non-trivial. union NotDeleted3f { const DefaultedDefCtor2 a; int b; }; // unexpected-note {{here}} -NotDeleted3f nd3f; // unexpected-error {{deleted constructor}} +NotDeleted3f nd3f; // unexpected-error {{implicitly-deleted default constructor}} // - X is a union and all of its variant members are of const-qualified type (or // array thereof), union Deleted4a { const int a; const int b; const UserProvidedDefCtor c; }; // expected-note {{here}} -Deleted4a d4a; // expected-error {{deleted constructor}} +Deleted4a d4a; // expected-error {{implicitly-deleted default constructor}} union Deleted4b { const int a; int b; }; Deleted4b d4b; // - X is a non-union class and all members of any anonymous union member are of // const-qualified type (or array thereof), struct Deleted5a { union { const int a; }; union { int b; }; }; // expected-note {{here}} -Deleted5a d5a; // expected-error {{deleted constructor}} +Deleted5a d5a; // expected-error {{implicitly-deleted default constructor}} struct Deleted5b { union { const int a; int b; }; union { const int c; int d; }; }; Deleted5b d5b; @@ -86,17 +89,17 @@ Deleted5b d5b; // constructor results in an ambiguity or in a function that is deleted or // inaccessible from the defaulted default constructor, or struct Deleted6a : Deleted2a {}; // expected-note {{here}} -Deleted6a d6a; // expected-error {{deleted constructor}} +Deleted6a d6a; // expected-error {{implicitly-deleted default constructor}} struct Deleted6b : virtual Deleted2a {}; // expected-note {{here}} -Deleted6b d6b; // expected-error {{deleted constructor}} +Deleted6b d6b; // expected-error {{implicitly-deleted default constructor}} struct Deleted6c { Deleted2a a; }; // expected-note {{here}} -Deleted6c d6c; // expected-error {{deleted constructor}} +Deleted6c d6c; // expected-error {{implicitly-deleted default constructor}} struct Deleted6d { DeletedDefCtor a; }; // expected-note {{here}} -Deleted6d d6d; // expected-error {{deleted constructor}} +Deleted6d d6d; // expected-error {{implicitly-deleted default constructor}} struct NotDeleted6a { DeletedDefCtor a = 0; }; NotDeleted6a nd6a; struct Deleted6e { PrivateDefCtor a; }; // expected-note {{here}} -Deleted6e d6e; // expected-error {{deleted constructor}} +Deleted6e d6e; // expected-error {{implicitly-deleted default constructor}} struct NotDeleted6b { PrivateDefCtor a = 0; }; NotDeleted6b nd6b; struct NotDeleted6c { Friend a; }; @@ -106,21 +109,21 @@ NotDeleted6c nd6c; // a destructor that is deleted or inaccessible from the defaulted default // constructor. struct Deleted7a : DeletedDtor {}; // expected-note {{here}} -Deleted7a d7a; // expected-error {{deleted constructor}} +Deleted7a d7a; // expected-error {{implicitly-deleted default constructor}} struct Deleted7b : virtual DeletedDtor {}; // expected-note {{here}} -Deleted7b d7b; // expected-error {{deleted constructor}} +Deleted7b d7b; // expected-error {{implicitly-deleted default constructor}} struct Deleted7c { DeletedDtor a; }; // expected-note {{here}} -Deleted7c d7c; // expected-error {{deleted constructor}} +Deleted7c d7c; // expected-error {{implicitly-deleted default constructor}} struct Deleted7d { DeletedDtor a = {}; }; // expected-note {{here}} -Deleted7d d7d; // expected-error {{deleted constructor}} +Deleted7d d7d; // expected-error {{implicitly-deleted default constructor}} struct Deleted7e : PrivateDtor {}; // expected-note {{here}} -Deleted7e d7e; // expected-error {{deleted constructor}} +Deleted7e d7e; // expected-error {{implicitly-deleted default constructor}} struct Deleted7f : virtual PrivateDtor {}; // expected-note {{here}} -Deleted7f d7f; // expected-error {{deleted constructor}} +Deleted7f d7f; // expected-error {{implicitly-deleted default constructor}} struct Deleted7g { PrivateDtor a; }; // expected-note {{here}} -Deleted7g d7g; // expected-error {{deleted constructor}} +Deleted7g d7g; // expected-error {{implicitly-deleted default constructor}} struct Deleted7h { PrivateDtor a = {}; }; // expected-note {{here}} -Deleted7h d7h; // expected-error {{deleted constructor}} +Deleted7h d7h; // expected-error {{implicitly-deleted default constructor}} struct NotDeleted7i : Friend {}; NotDeleted7i d7i; struct NotDeleted7j : virtual Friend {}; |