Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / member-init-anon-union.cpp
blob6c2f90d284b18f11674a7a8b27995958683a8f1e
1 // RUN: %clang_cc1 %s -std=c++11 -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s
3 // PR10531.
5 int make_a();
7 static union {
8 int a = make_a();
9 char *b;
12 int f() { return a; }
14 // CHECK-LABEL: define internal void @__cxx_global_var_init
15 // CHECK-NOT: }
16 // CHECK: call {{.*}}@"[[CONSTRUCT_GLOBAL:.*]]C1Ev"
19 int g() {
20 union {
21 int a;
22 int b = 81;
24 // CHECK-LABEL: define {{.*}}_Z1gv
25 // CHECK-NOT: }
26 // CHECK: call {{.*}}@"[[CONSTRUCT_LOCAL:.*]]C1Ev"
27 return b;
30 struct A {
31 A();
33 union B {
34 int k;
35 struct {
36 A x;
37 int y = 123;
39 B() {}
40 B(int n) : k(n) {}
43 B b1;
44 B b2(0);
46 // CHECK: define {{.*}}@"[[CONSTRUCT_GLOBAL]]C2Ev"
47 // CHECK-NOT: }
48 // CHECK: call {{.*}}@_Z6make_a
50 // CHECK: define {{.*}}@"[[CONSTRUCT_LOCAL]]C2Ev"
51 // CHECK-NOT: }
52 // CHECK: store i32 81
54 // CHECK-LABEL: define {{.*}} @_ZN1BC2Ev(
55 // CHECK: call void @_ZN1AC1Ev(
56 // CHECK: store i32 123,
57 // CHECK: }
59 // CHECK-LABEL: define {{.*}} @_ZN1BC2Ei(
60 // CHECK-NOT: call void @_ZN1AC1Ev(
61 // CHECK-NOT: store i32 123,
62 // CHECK: store i32 %
63 // CHECK-NOT: call void @_ZN1AC1Ev(
64 // CHECK-NOT: store i32 123,
65 // CHECK: }