summaryrefslogtreecommitdiffstats
path: root/test/CXX/special
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-03-03 23:51:05 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-03-03 23:51:05 +0000
commitec92bc78979aae6ec436fe51d082f7467e6f96c0 (patch)
tree504cf54faeeec4e6c9c8ab78267473d11f02e3c2 /test/CXX/special
parent1aa0be86358002fe876e5a4a00c3038c96be28ee (diff)
Add a pile of tests for unrestricted unions, and advertise support for them.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151992 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CXX/special')
-rw-r--r--test/CXX/special/class.copy/p11.0x.copy.cpp31
-rw-r--r--test/CXX/special/class.copy/p11.0x.move.cpp52
2 files changed, 83 insertions, 0 deletions
diff --git a/test/CXX/special/class.copy/p11.0x.copy.cpp b/test/CXX/special/class.copy/p11.0x.copy.cpp
index 65fd985924..cbe62b41cb 100644
--- a/test/CXX/special/class.copy/p11.0x.copy.cpp
+++ b/test/CXX/special/class.copy/p11.0x.copy.cpp
@@ -4,6 +4,9 @@ struct NonTrivial {
NonTrivial(const NonTrivial&);
};
+// A defaulted copy constructor for a class X is defined as deleted if X has:
+
+// -- a variant member with a non-trivial corresponding constructor
union DeletedNTVariant { // expected-note{{here}}
NonTrivial NT;
DeletedNTVariant();
@@ -20,6 +23,9 @@ struct DeletedNTVariant2 { // expected-note{{here}}
DeletedNTVariant2 DV2a;
DeletedNTVariant2 DV2b(DV2a); // expected-error{{call to implicitly-deleted copy constructor}}
+// -- a non-static data member of class type M (or array thereof) that cannot be
+// copied because overload resolution results in an ambiguity or a function
+// that is deleted or inaccessible
struct NoAccess {
NoAccess() = default;
private:
@@ -63,6 +69,25 @@ struct Deleted { // expected-note{{here}}
Deleted Da;
Deleted Db(Da); // expected-error{{call to implicitly-deleted copy constructor}}
+// -- a direct or virtual base class B that cannot be copied because overload
+// resolution results in an ambiguity or a function that is deleted or
+// inaccessible
+struct AmbiguousCopyBase : Ambiguity { // expected-note {{here}}
+ NonConst NC;
+};
+extern AmbiguousCopyBase ACBa;
+AmbiguousCopyBase ACBb(ACBa); // expected-error {{deleted copy constructor}}
+
+struct DeletedCopyBase : AmbiguousCopyBase {}; // expected-note {{here}}
+extern DeletedCopyBase DCBa;
+DeletedCopyBase DCBb(DCBa); // expected-error {{deleted copy constructor}}
+
+struct InaccessibleCopyBase : NoAccess {}; // expected-note {{here}}
+extern InaccessibleCopyBase ICBa;
+InaccessibleCopyBase ICBb(ICBa); // expected-error {{deleted copy constructor}}
+
+// -- any direct or virtual base class or non-static data member of a type with
+// a destructor that is deleted or inaccessible
struct NoAccessDtor {
private:
~NoAccessDtor();
@@ -83,6 +108,12 @@ struct HasAccessDtor {
HasAccessDtor HADa;
HasAccessDtor HADb(HADa);
+struct HasNoAccessDtorBase : NoAccessDtor { // expected-note{{here}}
+};
+extern HasNoAccessDtorBase HNADBa;
+HasNoAccessDtorBase HNADBb(HNADBa); // expected-error{{implicitly-deleted copy constructor}}
+
+// -- a non-static data member of rvalue reference type
struct RValue { // expected-note{{here}}
int && ri = 1;
};
diff --git a/test/CXX/special/class.copy/p11.0x.move.cpp b/test/CXX/special/class.copy/p11.0x.move.cpp
index 402bc31d5e..5315b060a0 100644
--- a/test/CXX/special/class.copy/p11.0x.move.cpp
+++ b/test/CXX/special/class.copy/p11.0x.move.cpp
@@ -4,6 +4,9 @@ struct NonTrivial {
NonTrivial(NonTrivial&&);
};
+// A defaulted move constructor for a class X is defined as deleted if X has:
+
+// -- a variant member with a non-trivial corresponding constructor
union DeletedNTVariant {
NonTrivial NT;
DeletedNTVariant(DeletedNTVariant&&);
@@ -18,6 +21,9 @@ struct DeletedNTVariant2 {
};
DeletedNTVariant2::DeletedNTVariant2(DeletedNTVariant2&&) = default; // expected-error{{would delete}}
+// -- a non-static data member of class type M (or array thereof) that cannot be
+// copied because overload resolution results in an ambiguity or a function
+// that is deleted or inaccessible
struct NoAccess {
NoAccess() = default;
private:
@@ -38,6 +44,43 @@ struct HasAccess {
};
HasAccess::HasAccess(HasAccess&&) = default;
+struct Ambiguity {
+ Ambiguity(const Ambiguity&&);
+ Ambiguity(volatile Ambiguity&&);
+};
+
+struct IsAmbiguous {
+ Ambiguity A;
+ IsAmbiguous(IsAmbiguous&&);
+};
+IsAmbiguous::IsAmbiguous(IsAmbiguous&&) = default; // expected-error{{would delete}}
+
+struct Deleted {
+ IsAmbiguous IA;
+ Deleted(Deleted&&);
+};
+Deleted::Deleted(Deleted&&) = default; // expected-error{{would delete}}
+
+// -- a direct or virtual base class B that cannot be moved because overload
+// resolution results in an ambiguity or a function that is deleted or
+// inaccessible
+struct AmbiguousMoveBase : Ambiguity {
+ AmbiguousMoveBase(AmbiguousMoveBase&&);
+};
+AmbiguousMoveBase::AmbiguousMoveBase(AmbiguousMoveBase&&) = default; // expected-error{{would delete}}
+
+struct DeletedMoveBase : AmbiguousMoveBase {
+ DeletedMoveBase(DeletedMoveBase&&);
+};
+DeletedMoveBase::DeletedMoveBase(DeletedMoveBase&&) = default; // expected-error{{would delete}}
+
+struct InaccessibleMoveBase : NoAccess {
+ InaccessibleMoveBase(InaccessibleMoveBase&&);
+};
+InaccessibleMoveBase::InaccessibleMoveBase(InaccessibleMoveBase&&) = default; // expected-error{{would delete}}
+
+// -- any direct or virtual base class or non-static data member of a type with
+// a destructor that is deleted or inaccessible
struct NoAccessDtor {
NoAccessDtor(NoAccessDtor&&);
private:
@@ -57,12 +100,21 @@ struct HasAccessDtor {
};
HasAccessDtor::HasAccessDtor(HasAccessDtor&&) = default;
+struct HasNoAccessDtorBase : NoAccessDtor { // expected-note{{here}}
+};
+extern HasNoAccessDtorBase HNADBa;
+HasNoAccessDtorBase HNADBb(HNADBa); // expected-error{{implicitly-deleted copy constructor}}
+
+// The restriction on rvalue reference members applies to only the copy
+// constructor.
struct RValue {
int &&ri = 1;
RValue(RValue&&);
};
RValue::RValue(RValue&&) = default;
+// -- a non-static data member or direct or virtual base class with a type that
+// does not have a move constructor and is not trivially copyable
struct CopyOnly {
CopyOnly(const CopyOnly&);
};