summaryrefslogtreecommitdiffstats
path: root/test/CXX/class/class.union/p1.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/CXX/class/class.union/p1.cpp')
-rw-r--r--test/CXX/class/class.union/p1.cpp59
1 files changed, 34 insertions, 25 deletions
diff --git a/test/CXX/class/class.union/p1.cpp b/test/CXX/class/class.union/p1.cpp
index ee97410..439cc9c 100644
--- a/test/CXX/class/class.union/p1.cpp
+++ b/test/CXX/class/class.union/p1.cpp
@@ -14,25 +14,25 @@ class VirtualBase : virtual Okay { // expected-note 4 {{because type 'VirtualBas
};
class Ctor {
- Ctor() { abort(); } // expected-note 4 {{because type 'Ctor' has a user-declared constructor}}
+ Ctor() { abort(); } // expected-note 2{{because type 'Ctor' has a user-provided default constructor}} expected-note 2{{here}}
};
class Ctor2 {
- Ctor2(); // expected-note 3 {{because type 'Ctor2' has a user-declared constructor}}
+ Ctor2(); // expected-note {{because type 'Ctor2' has a user-provided default constructor}} expected-note 2{{here}}
};
-class CtorTmpl {
- template<typename T> CtorTmpl(); // expected-note {{because type 'CtorTmpl' has a user-declared constructor}}
+class CtorTmpl { // expected-note {{because type 'CtorTmpl' has no default constructor}}
+ template<typename T> CtorTmpl(); // expected-note {{implicit default constructor suppressed by user-declared constructor}}
};
-class CopyCtor {
- CopyCtor(CopyCtor &cc) { abort(); } // expected-note 4 {{because type 'CopyCtor' has a user-declared copy constructor}}
+class CopyCtor { // expected-note 2{{because no constructor can be used to copy an object of type 'const CopyCtor'}}
+ CopyCtor(CopyCtor &cc) { abort(); }
};
-class CopyAssign {
- CopyAssign& operator=(CopyAssign& CA) { abort(); } // expected-note 4 {{because type 'CopyAssign' has a user-declared copy assignment operator}}
+class CopyAssign { // expected-note 2 {{because no assignment operator can be used to copy an object of type 'const CopyAssign'}}
+ CopyAssign& operator=(CopyAssign& CA) { abort(); }
};
class Dtor {
- ~Dtor() { abort(); } // expected-note 4 {{because type 'Dtor' has a user-declared destructor}}
+ ~Dtor() { abort(); } // expected-note 2 {{because type 'Dtor' has a user-provided destructor}} expected-note 2{{here}}
};
union U1 {
@@ -49,25 +49,25 @@ union U1 {
union U2 {
struct {
- Virtual v; // expected-note {{because type 'U2::<anonymous struct}}
+ Virtual v; // expected-note {{because the function selected to copy field of type 'Virtual' is not trivial}}
} m1; // expected-error {{union member 'm1' has a non-trivial copy constructor}}
struct {
- VirtualBase vbase; // expected-note {{because type 'U2::<anonymous struct}}
+ VirtualBase vbase; // expected-note {{because the function selected to copy field of type 'VirtualBase' is not trivial}}
} m2; // expected-error {{union member 'm2' has a non-trivial copy constructor}}
struct {
- Ctor ctor; // expected-note {{because type 'U2::<anonymous struct}}
+ Ctor ctor; // expected-note {{because field of type 'Ctor' has a user-provided default constructor}}
} m3; // expected-error {{union member 'm3' has a non-trivial constructor}}
struct {
- Ctor2 ctor2; // expected-note {{because type 'U2::<anonymous struct}}
+ Ctor2 ctor2; // expected-note {{because field of type 'Ctor2' has a user-provided default constructor}}
} m3a; // expected-error {{union member 'm3a' has a non-trivial constructor}}
- struct {
- CopyCtor copyctor; // expected-note {{because type 'U2::<anonymous struct}}
+ struct { // expected-note {{no constructor can be used to copy an object of type 'const}}
+ CopyCtor copyctor;
} m4; // expected-error {{union member 'm4' has a non-trivial copy constructor}}
- struct {
- CopyAssign copyassign; // expected-note {{because type 'U2::<anonymous struct}}
+ struct { // expected-note {{no assignment operator can be used to copy an object of type 'const}}
+ CopyAssign copyassign;
} m5; // expected-error {{union member 'm5' has a non-trivial copy assignment operator}}
struct {
- Dtor dtor; // expected-note {{because type 'U2::<anonymous struct}}
+ Dtor dtor; // expected-note {{because field of type 'Dtor' has a user-provided destructor}}
} m6; // expected-error {{union member 'm6' has a non-trivial destructor}}
struct {
Okay okay;
@@ -75,22 +75,25 @@ union U2 {
};
union U3 {
- struct s1 : Virtual { // expected-note {{because type 'U3::s1' has a base class with a non-trivial copy constructor}}
+ struct s1 : Virtual { // expected-note {{because the function selected to copy base class of type 'Virtual' is not trivial}}
} m1; // expected-error {{union member 'm1' has a non-trivial copy constructor}}
- struct s2 : VirtualBase { // expected-note {{because type 'U3::s2' has a base class with a non-trivial copy constructor}}
+ struct s2 : VirtualBase { // expected-note {{because the function selected to copy base class of type 'VirtualBase' is not trivial}}
} m2; // expected-error {{union member 'm2' has a non-trivial copy constructor}}
- struct s3 : Ctor { // expected-note {{because type 'U3::s3' has a base class with a non-trivial constructor}}
+ struct s3 : Ctor { // expected-note {{because base class of type 'Ctor' has a user-provided default constructor}}
} m3; // expected-error {{union member 'm3' has a non-trivial constructor}}
- struct s3a : Ctor2 { // expected-note {{because type 'U3::s3a' has a base class with a non-trivial constructor}}
+ struct s3a : Ctor2 { // expected-note {{because base class of type 'Ctor2' has a user-provided default constructor}}
} m3a; // expected-error {{union member 'm3a' has a non-trivial constructor}}
- struct s4 : CopyCtor { // expected-note {{because type 'U3::s4' has a base class with a non-trivial copy constructor}}
+ struct s4 : CopyCtor { // expected-note {{because no constructor can be used to copy an object of type 'const U3::s4'}}
} m4; // expected-error {{union member 'm4' has a non-trivial copy constructor}}
- struct s5 : CopyAssign { // expected-note {{because type 'U3::s5' has a base class with a non-trivial copy assignment operator}}
+ struct s5 : CopyAssign { // expected-note {{because no assignment operator can be used to copy an object of type 'const U3::s5'}}
} m5; // expected-error {{union member 'm5' has a non-trivial copy assignment operator}}
- struct s6 : Dtor { // expected-note {{because type 'U3::s6' has a base class with a non-trivial destructor}}
+ struct s6 : Dtor { // expected-note {{because base class of type 'Dtor' has a user-provided destructor}}
} m6; // expected-error {{union member 'm6' has a non-trivial destructor}}
struct s7 : Okay {
} m7;
+ struct s8 {
+ s8(...) = delete; // expected-note {{because it is a variadic function}} expected-warning {{C++11}}
+ } m8; // expected-error {{union member 'm8' has a non-trivial constructor}}
};
union U4 {
@@ -102,6 +105,12 @@ union U5 {
int& i1; // expected-error {{union member 'i1' has reference type 'int &'}}
};
+union U6 {
+ struct S {
+ int &i;
+ } s; // ok
+};
+
template <class A, class B> struct Either {
bool tag;
union { // expected-note 6 {{in instantiation of member class}}
OpenPOWER on IntegriCloud