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