cxx1z-initializer-aggregate.cpp
4.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// RUN: %clang_cc1 -std=c++1z %s -triple x86_64-linux-gnu -fexceptions -fcxx-exceptions -emit-llvm -o - | FileCheck %s
namespace Constant {
struct A {
int n;
char k;
~A();
};
struct B {
char k2;
};
struct C : B {};
struct D : A, C {};
C c1 = {};
C c2 = {1};
// CHECK: @_ZN8Constant2c1E = global { i8 } zeroinitializer, align 1
// CHECK: @_ZN8Constant2c2E = global { i8 } { i8 1 }, align 1
// Test packing bases into tail padding.
D d1 = {};
D d2 = {1, 2, 3};
D d3 = {1};
// CHECK: @_ZN8Constant2d1E = global { i32, i8, i8 } zeroinitializer, align 4
// CHECK: @_ZN8Constant2d2E = global { i32, i8, i8 } { i32 1, i8 2, i8 3 }, align 4
// CHECK: @_ZN8Constant2d3E = global { i32, i8, i8 } { i32 1, i8 0, i8 0 }, align 4
// CHECK-LABEL: define {{.*}}global_var_init
// CHECK: call {{.*}} @__cxa_atexit({{.*}} @_ZN8Constant1DD1Ev {{.*}} @_ZN8Constant2d1E
// CHECK-LABEL: define {{.*}}global_var_init
// CHECK: call {{.*}} @__cxa_atexit({{.*}} @_ZN8Constant1DD1Ev {{.*}} @_ZN8Constant2d2E
// CHECK-LABEL: define {{.*}}global_var_init
// CHECK: call {{.*}} @__cxa_atexit({{.*}} @_ZN8Constant1DD1Ev {{.*}} @_ZN8Constant2d3E
}
namespace Dynamic {
struct A {
A();
A(int);
A(const char*, unsigned);
~A();
void *p;
};
struct B {
~B();
int n = 5;
};
struct C {
C(bool = true);
};
int f(), g(), h(), i();
struct D : A, B, C {
int n = f();
};
D d1 = {};
// CHECK-LABEL: define {{.*}}global_var_init
// CHECK: call void @_ZN7Dynamic1AC2Ev({{.*}} @_ZN7Dynamic2d1E
// CHECK: store i32 5, {{.*}}i8* getelementptr inbounds {{.*}} @_ZN7Dynamic2d1E{{.*}}, i64 8
// CHECK: invoke void @_ZN7Dynamic1CC2Eb({{.*}} @_ZN7Dynamic2d1E{{.*}}, i1 zeroext true)
// CHECK: unwind label %[[UNWIND:.*]]
// CHECK: invoke i32 @_ZN7Dynamic1fEv()
// CHECK: unwind label %[[UNWIND:.*]]
// CHECK: store i32 {{.*}}, i32* getelementptr {{.*}} @_ZN7Dynamic2d1E, i32 0, i32 2
// CHECK: call {{.*}} @__cxa_atexit({{.*}} @_ZN7Dynamic1DD1Ev {{.*}} @_ZN7Dynamic2d1E
// CHECK: ret
//
// UNWIND:
// CHECK: call void @_ZN7Dynamic1BD1Ev({{.*}}i8* getelementptr inbounds {{.*}} @_ZN7Dynamic2d1E{{.*}}, i64 8
// CHECK: call void @_ZN7Dynamic1AD1Ev({{.*}} @_ZN7Dynamic2d1E
D d2 = {1, 2, false};
// CHECK-LABEL: define {{.*}}global_var_init
// CHECK: call void @_ZN7Dynamic1AC1Ei({{.*}} @_ZN7Dynamic2d2E{{.*}}, i32 1)
// CHECK: store i32 2, {{.*}}i8* getelementptr inbounds {{.*}}@_ZN7Dynamic2d2E{{.*}}, i64 8
// CHECK: invoke void @_ZN7Dynamic1CC1Eb({{.*}} @_ZN7Dynamic2d2E{{.*}}, i1 zeroext false)
// CHECK: invoke i32 @_ZN7Dynamic1fEv()
// CHECK: store i32 {{.*}}, i32* getelementptr {{.*}} @_ZN7Dynamic2d2E, i32 0, i32 2
// CHECK: call {{.*}} @__cxa_atexit({{.*}} @_ZN7Dynamic1DD1Ev {{.*}} @_ZN7Dynamic2d2E
// CHECK: ret void
D d3 = {g(), h(), {}, i()};
// CHECK-LABEL: define {{.*}}global_var_init
// CHECK: %[[G_CALL:.*]] = call i32 @_ZN7Dynamic1gEv()
// CHECK: call void @_ZN7Dynamic1AC1Ei({{.*}} @_ZN7Dynamic2d3E{{.*}}, i32 %[[G_CALL]])
// CHECK: %[[H_CALL:.*]] = invoke i32 @_ZN7Dynamic1hEv()
// CHECK: unwind label %[[DESTROY_A_LPAD:.*]]
// CHECK: store i32 %[[H_CALL]], {{.*}}i8* getelementptr inbounds {{.*}} @_ZN7Dynamic2d3E{{.*}}, i64 8
// CHECK: invoke void @_ZN7Dynamic1CC2Eb({{.*}} @_ZN7Dynamic2d3E{{.*}}, i1 zeroext true)
// CHECK: unwind label %[[DESTROY_AB_LPAD:.*]]
// CHECK: %[[I_CALL:.*]] = invoke i32 @_ZN7Dynamic1iEv()
// CHECK: unwind label %[[DESTROY_AB_LPAD:.*]]
// CHECK: store i32 %[[I_CALL]], i32* getelementptr {{.*}} @_ZN7Dynamic2d3E, i32 0, i32 2
// CHECK: call {{.*}} @__cxa_atexit({{.*}} @_ZN7Dynamic1DD1Ev {{.*}} @_ZN7Dynamic2d3E to i8*
// CHECK: ret
//
// DESTROY_A_LPAD:
// CHECK: br label %[[A_CLEANUP:.*]]
//
// DESTROY_B_LPAD:
// CHECK: call void @_ZN7Dynamic1BD1Ev({{.*}}i8* getelementptr inbounds {{.*}} @_ZN7Dynamic2d3E{{.*}}, i64 8
// CHECK: br label %[[A_CLEANUP:.*]]
//
// A_CLEANUP:
// CHECK: call void @_ZN7Dynamic1AD1Ev({{.*}} @_ZN7Dynamic2d3E
}
namespace Instantiated1 {
struct A { A(); };
struct B : A { using A::A; };
template<int> B v({});
template B v<0>;
// CHECK-LABEL: define {{.*}}global_var_init{{.*}} comdat($_ZN13Instantiated11vILi0EEE) {
// CHECK: call void @_ZN13Instantiated11BC1Ev(%{{.*}}* @_ZN13Instantiated11vILi0EEE)
}
namespace Instantiated2 {
struct A { A(); };
struct B : A {};
template<int> B v({});
template B v<0>;
// CHECK-LABEL: define {{.*}}global_var_init{{.*}} comdat($_ZN13Instantiated21vILi0EEE) {
// CHECK: call void @_ZN13Instantiated21AC2Ev(
}