xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/member-init-anon-union.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - | FileCheck %s
2*f4a2713aSLionel Sambuc 
3*f4a2713aSLionel Sambuc // PR10531.
4*f4a2713aSLionel Sambuc 
5*f4a2713aSLionel Sambuc int make_a();
6*f4a2713aSLionel Sambuc 
7*f4a2713aSLionel Sambuc static union {
8*f4a2713aSLionel Sambuc   int a = make_a();
9*f4a2713aSLionel Sambuc   char *b;
10*f4a2713aSLionel Sambuc };
11*f4a2713aSLionel Sambuc 
12*f4a2713aSLionel Sambuc int f() { return a; }
13*f4a2713aSLionel Sambuc 
14*f4a2713aSLionel Sambuc // CHECK-LABEL: define internal void @__cxx_global_var_init
15*f4a2713aSLionel Sambuc // CHECK-NOT: }
16*f4a2713aSLionel Sambuc // CHECK: call {{.*}}@"[[CONSTRUCT_GLOBAL:.*]]C1Ev"
17*f4a2713aSLionel Sambuc 
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc int g() {
20*f4a2713aSLionel Sambuc   union {
21*f4a2713aSLionel Sambuc     int a;
22*f4a2713aSLionel Sambuc     int b = 81;
23*f4a2713aSLionel Sambuc   };
24*f4a2713aSLionel Sambuc   // CHECK: define {{.*}}_Z1gv
25*f4a2713aSLionel Sambuc   // CHECK-NOT: }
26*f4a2713aSLionel Sambuc   // CHECK: call {{.*}}@"[[CONSTRUCT_LOCAL:.*]]C1Ev"
27*f4a2713aSLionel Sambuc   return b;
28*f4a2713aSLionel Sambuc }
29*f4a2713aSLionel Sambuc 
30*f4a2713aSLionel Sambuc 
31*f4a2713aSLionel Sambuc // CHECK: define {{.*}}@"[[CONSTRUCT_LOCAL]]C2Ev"
32*f4a2713aSLionel Sambuc // CHECK-NOT: }
33*f4a2713aSLionel Sambuc // CHECK: store i32 81
34*f4a2713aSLionel Sambuc 
35*f4a2713aSLionel Sambuc // CHECK: define {{.*}}@"[[CONSTRUCT_GLOBAL]]C2Ev"
36*f4a2713aSLionel Sambuc // CHECK-NOT: }
37*f4a2713aSLionel Sambuc // CHECK: call {{.*}}@_Z6make_a
38