xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/cxx11-unrestricted-union.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 -std=c++11 -emit-llvm %s -o - | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc struct A {
4*f4a2713aSLionel Sambuc   A(); A(const A&); A(A&&); A &operator=(const A&); A &operator=(A&&); ~A();
5*f4a2713aSLionel Sambuc };
6*f4a2713aSLionel Sambuc struct B {
7*f4a2713aSLionel Sambuc   B(); B(const B&); B(B&&); B &operator=(const B&); B &operator=(B&&); ~B();
8*f4a2713aSLionel Sambuc };
9*f4a2713aSLionel Sambuc 
10*f4a2713aSLionel Sambuc union U {
11*f4a2713aSLionel Sambuc   U();
12*f4a2713aSLionel Sambuc   U(const U &);
13*f4a2713aSLionel Sambuc   U(U &&);
14*f4a2713aSLionel Sambuc   U &operator=(const U&);
15*f4a2713aSLionel Sambuc   U &operator=(U&&);
16*f4a2713aSLionel Sambuc   ~U();
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc   A a;
19*f4a2713aSLionel Sambuc   int n;
20*f4a2713aSLionel Sambuc };
21*f4a2713aSLionel Sambuc 
22*f4a2713aSLionel Sambuc // CHECK-NOT: _ZN1A
23*f4a2713aSLionel Sambuc U::U() {}
24*f4a2713aSLionel Sambuc U::U(const U&) {}
25*f4a2713aSLionel Sambuc U::U(U&&) {}
26*f4a2713aSLionel Sambuc U &U::operator=(const U&) { return *this; }
27*f4a2713aSLionel Sambuc U &U::operator=(U &&) { return *this; }
28*f4a2713aSLionel Sambuc U::~U() {}
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc struct S {
31*f4a2713aSLionel Sambuc   S();
32*f4a2713aSLionel Sambuc   S(const S &);
33*f4a2713aSLionel Sambuc   S(S &&);
34*f4a2713aSLionel Sambuc   S &operator=(const S&);
35*f4a2713aSLionel Sambuc   S &operator=(S&&);
36*f4a2713aSLionel Sambuc   ~S();
37*f4a2713aSLionel Sambuc 
38*f4a2713aSLionel Sambuc   union {
39*f4a2713aSLionel Sambuc     A a;
40*f4a2713aSLionel Sambuc     int n;
41*f4a2713aSLionel Sambuc   };
42*f4a2713aSLionel Sambuc   B b;
43*f4a2713aSLionel Sambuc   int m;
44*f4a2713aSLionel Sambuc };
45*f4a2713aSLionel Sambuc 
46*f4a2713aSLionel Sambuc // CHECK: _ZN1SC2Ev
47*f4a2713aSLionel Sambuc // CHECK-NOT: _ZN1A
48*f4a2713aSLionel Sambuc // CHECK: _ZN1BC1Ev
49*f4a2713aSLionel Sambuc S::S() {}
50*f4a2713aSLionel Sambuc 
51*f4a2713aSLionel Sambuc // CHECK-NOT: _ZN1A
52*f4a2713aSLionel Sambuc 
53*f4a2713aSLionel Sambuc // CHECK: _ZN1SC2ERKS_
54*f4a2713aSLionel Sambuc // CHECK-NOT: _ZN1A
55*f4a2713aSLionel Sambuc // CHECK: _ZN1BC1Ev
56*f4a2713aSLionel Sambuc S::S(const S&) {}
57*f4a2713aSLionel Sambuc 
58*f4a2713aSLionel Sambuc // CHECK-NOT: _ZN1A
59*f4a2713aSLionel Sambuc 
60*f4a2713aSLionel Sambuc // CHECK: _ZN1SC2EOS_
61*f4a2713aSLionel Sambuc // CHECK-NOT: _ZN1A
62*f4a2713aSLionel Sambuc // CHECK: _ZN1BC1Ev
63*f4a2713aSLionel Sambuc S::S(S&&) {}
64*f4a2713aSLionel Sambuc 
65*f4a2713aSLionel Sambuc // CHECK-NOT: _ZN1A
66*f4a2713aSLionel Sambuc // CHECK-NOT: _ZN1B
67*f4a2713aSLionel Sambuc S &S::operator=(const S&) { return *this; }
68*f4a2713aSLionel Sambuc 
69*f4a2713aSLionel Sambuc S &S::operator=(S &&) { return *this; }
70*f4a2713aSLionel Sambuc 
71*f4a2713aSLionel Sambuc // CHECK: _ZN1SD2Ev
72*f4a2713aSLionel Sambuc // CHECK-NOT: _ZN1A
73*f4a2713aSLionel Sambuc // CHECK: _ZN1BD1Ev
74*f4a2713aSLionel Sambuc S::~S() {}
75*f4a2713aSLionel Sambuc 
76*f4a2713aSLionel Sambuc // CHECK-NOT: _ZN1A
77