1 // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
8 // CHECK: @u ={{.*}} global %union.anon zeroinitializer
9 union { int i
; float f
; } u
= { };
11 // CHECK: @u2 ={{.*}} global { i32, [4 x i8] } zeroinitializer
12 union { int i
; double f
; } u2
= { };
14 // CHECK: @u3 ={{.*}} global %union.anon.1 zeroinitializer
15 union { double f
; int i
; } u3
= { };
17 // CHECK: @b ={{.*}} global [2 x i32] [i32 0, i32 22]
36 // Traditional C anonymous member init
37 struct ds ds0
= { { { .a
= 0 } } };
38 // C1X lookup-based anonymous member init cases
39 struct ds ds1
= { { .a
= 1 } };
40 struct ds ds2
= { { .b
= 1 } };
41 struct ds ds3
= { .a
= 0 };
42 // CHECK: @ds4 ={{.*}} global %struct.ds { %struct.anon.3 { %struct.anon zeroinitializer, i16 0, %struct.anon.2 { i16 1 } } }
43 struct ds ds4
= { .c
= 1 };
44 struct ds ds5
= { { { .a
= 0 } }, .b
= 1 };
45 struct ds ds6
= { { .a
= 0, .b
= 1 } };
46 // CHECK: @ds7 ={{.*}} global %struct.ds { %struct.anon.3 { %struct.anon { i16 2 }, i16 3, %struct.anon.2 zeroinitializer } }
56 struct overwrite_string_struct1
{
57 __typeof(L
"foo"[0]) L
[6];
59 } overwrite_string1
[] = { { { L
"foo" }, 1 }, [0].L
[2] = L
'x'};
60 // CHECK: [6 x i32] [i32 102, i32 111, i32 120, i32 0, i32 0, i32 0], i32 1
61 struct overwrite_string_struct2
{
64 } overwrite_string2
[] = { { { "foo" }, 1 }, [0].L
[2] = 'x'};
65 // CHECK: [6 x i8] c"fox\00\00\00", [2 x i8] zeroinitializer, i32 1
66 struct overwrite_string_struct3
{
69 } overwrite_string3
[] = { { { "foo" }, 1 }, [0].L
[2] = 'x'};
70 // CHECK: [3 x i8] c"fox", i8 0, i32 1
71 struct overwrite_string_struct4
{
74 } overwrite_string4
[] = { { { "foobar" }, 1 }, [0].L
[2] = 'x'};
75 // CHECK: [3 x i8] c"fox", i8 0, i32 1
76 struct overwrite_string_struct5
{
79 } overwrite_string5
[] = { { { "foo" }, 1 }, [0].L
[4] = 'y'};
80 // CHECK: [6 x i8] c"foo\00y\00", [2 x i8] zeroinitializer, i32 1
83 // CHECK: @u1 = {{.*}} { i32 65535 }
84 union u_FFFF
{ char c
; long l
; } u1
= { .l
= 0xFFFF };
88 typedef union u_16644
{
98 // CHECK: @union_16644_instance_0 = {{.*}} { i32 0, i32 0, i32 0, i32 3 } }
99 union_16644_t union_16644_instance_0
=
107 // CHECK: @union_16644_instance_1 = {{.*}} [i32 10, i32 0, i32 0, i32 0]
108 union_16644_t union_16644_instance_1
=
116 // CHECK: @union_16644_instance_2 = {{.*}} [i32 0, i32 20, i32 0, i32 0]
117 union_16644_t union_16644_instance_2
=
123 // CHECK: @union_16644_instance_3 = {{.*}} { i32 0, i32 31, i32 0, i32 0 }
124 union_16644_t union_16644_instance_3
=
132 // CHECK: @union_16644_instance_4 = {{.*}} { i32 5, i32 2, i32 0, i32 0 } {{.*}} [i32 0, i32 4, i32 0, i32 0]
133 union_16644_t union_16644_instance_4
[2] =
141 // CHECK: @lab ={{.*}} global { [4 x i8], i32 } { [4 x i8] zeroinitializer, i32 123 }
142 struct leading_anon_bitfield
{ int : 32; int n
; } lab
= { .n
= 123 };
152 struct Derived D
= {{}, .B
.A
= 42};
153 // CHECK: @D ={{.*}} global %struct.Derived { %struct.Base { %struct.anon.4 { i32 42 } } }, align 4
155 void test1(int argc
, char **argv
)
157 // CHECK: internal global %struct.foo { ptr null, i32 1024 }
158 static struct foo foo
= {
162 // CHECK: call void @llvm.memset
163 union { int i
; float f
; } u2
= { };
165 // CHECK-NOT: call void @llvm.memset
166 union { int i
; float f
; } u3
;