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