1 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 void abort() __attribute__((noreturn
));
10 virtual void foo() { abort(); } // expected-note 4 {{because type 'Virtual' has a virtual member function}}
13 class VirtualBase
: virtual Okay
{ // expected-note 4 {{because type 'VirtualBase' has a virtual base class}}
17 Ctor() { abort(); } // expected-note 2{{because type 'Ctor' has a user-provided default constructor}} expected-note 2{{here}}
20 Ctor2(); // expected-note {{because type 'Ctor2' has a user-provided default constructor}} expected-note 2{{here}}
22 class CtorTmpl
{ // expected-note {{because type 'CtorTmpl' has no default constructor}}
23 template<typename T
> CtorTmpl(); // expected-note {{implicit default constructor suppressed by user-declared constructor}}
26 class CopyCtor
{ // expected-note 2{{because no constructor can be used to copy an object of type 'const CopyCtor'}}
27 CopyCtor(CopyCtor
&cc
) { abort(); }
30 class CopyAssign
{ // expected-note 2 {{because no assignment operator can be used to copy an object of type 'const CopyAssign'}}
31 CopyAssign
& operator=(CopyAssign
& CA
) { abort(); }
35 ~Dtor() { abort(); } // expected-note 2 {{because type 'Dtor' has a user-provided destructor}} expected-note 2{{here}}
39 Virtual v
; // expected-error {{union member 'v' has a non-trivial copy constructor}}
40 VirtualBase vbase
; // expected-error {{union member 'vbase' has a non-trivial copy constructor}}
41 Ctor ctor
; // expected-error {{union member 'ctor' has a non-trivial default constructor}}
42 Ctor2 ctor2
; // expected-error {{union member 'ctor2' has a non-trivial default constructor}}
43 CtorTmpl ctortmpl
; // expected-error {{union member 'ctortmpl' has a non-trivial default constructor}}
44 CopyCtor copyctor
; // expected-error {{union member 'copyctor' has a non-trivial copy constructor}}
45 CopyAssign copyassign
; // expected-error {{union member 'copyassign' has a non-trivial copy assignment operator}}
46 Dtor dtor
; // expected-error {{union member 'dtor' has a non-trivial destructor}}
52 Virtual v
; // expected-note {{because the function selected to copy field of type 'Virtual' is not trivial}}
53 } m1
; // expected-error {{union member 'm1' has a non-trivial copy constructor}}
55 VirtualBase vbase
; // expected-note {{because the function selected to copy field of type 'VirtualBase' is not trivial}}
56 } m2
; // expected-error {{union member 'm2' has a non-trivial copy constructor}}
58 Ctor ctor
; // expected-note {{because field of type 'Ctor' has a user-provided default constructor}}
59 } m3
; // expected-error {{union member 'm3' has a non-trivial default constructor}}
61 Ctor2 ctor2
; // expected-note {{because field of type 'Ctor2' has a user-provided default constructor}}
62 } m3a
; // expected-error {{union member 'm3a' has a non-trivial default constructor}}
63 struct { // expected-note {{no constructor can be used to copy an object of type 'const}}
65 } m4
; // expected-error {{union member 'm4' has a non-trivial copy constructor}}
66 struct { // expected-note {{no assignment operator can be used to copy an object of type 'const}}
67 CopyAssign copyassign
;
68 } m5
; // expected-error {{union member 'm5' has a non-trivial copy assignment operator}}
70 Dtor dtor
; // expected-note {{because field of type 'Dtor' has a user-provided destructor}}
71 } m6
; // expected-error {{union member 'm6' has a non-trivial destructor}}
78 struct s1
: Virtual
{ // expected-note {{because the function selected to copy base class of type 'Virtual' is not trivial}}
79 } m1
; // expected-error {{union member 'm1' has a non-trivial copy constructor}}
80 struct s2
: VirtualBase
{ // expected-note {{because the function selected to copy base class of type 'VirtualBase' is not trivial}}
81 } m2
; // expected-error {{union member 'm2' has a non-trivial copy constructor}}
82 struct s3
: Ctor
{ // expected-note {{because base class of type 'Ctor' has a user-provided default constructor}}
83 } m3
; // expected-error {{union member 'm3' has a non-trivial default constructor}}
84 struct s3a
: Ctor2
{ // expected-note {{because base class of type 'Ctor2' has a user-provided default constructor}}
85 } m3a
; // expected-error {{union member 'm3a' has a non-trivial default constructor}}
86 struct s4
: CopyCtor
{ // expected-note {{because no constructor can be used to copy an object of type 'const U3::s4'}}
87 } m4
; // expected-error {{union member 'm4' has a non-trivial copy constructor}}
88 struct s5
: CopyAssign
{ // expected-note {{because no assignment operator can be used to copy an object of type 'const U3::s5'}}
89 } m5
; // expected-error {{union member 'm5' has a non-trivial copy assignment operator}}
90 struct s6
: Dtor
{ // expected-note {{because base class of type 'Dtor' has a user-provided destructor}}
91 } m6
; // expected-error {{union member 'm6' has a non-trivial destructor}}
95 s8(...) = delete; // expected-note {{because it is a variadic function}} expected-warning {{C++11}}
96 } m8
; // expected-error {{union member 'm8' has a non-trivial default constructor}}
100 static int i1
; // expected-warning {{static data member 'i1' in union is a C++11 extension}}
105 int& i1
; // expected-error {{union member 'i1' has reference type 'int &'}}
114 template <class A
, class B
> struct Either
{
116 union { // expected-note 6 {{in instantiation of member class}}
118 B b
; // expected-error 6 {{non-trivial}}
121 Either(const A
& a
) : tag(true), a(a
) {}
122 Either(const B
& b
) : tag(false), b(b
) {}
126 Either
<int,Virtual
> virt(0); // expected-note {{in instantiation of template}}
127 Either
<int,VirtualBase
> vbase(0); // expected-note {{in instantiation of template}}
128 Either
<int,Ctor
> ctor(0); // expected-note {{in instantiation of template}}
129 Either
<int,CopyCtor
> copyctor(0); // expected-note {{in instantiation of template}}
130 Either
<int,CopyAssign
> copyassign(0); // expected-note {{in instantiation of template}}
131 Either
<int,Dtor
> dtor(0); // expected-note {{in instantiation of template}}
132 Either
<int,Okay
> okay(0);