[Heikki Kultala] This patch contains the ABI changes for the TCE target.
[clang.git] / test / CodeGen / designated-initializers.c
blobd928296ef23015809b8fb5f868b4169b251d58c7
1 // RUN: %clang_cc1 -triple i386-unknown-unknown %s -emit-llvm -o - | FileCheck %s
3 struct foo {
4 void *a;
5 int b;
6 };
8 // CHECK: @u = global %union.anon zeroinitializer
9 union { int i; float f; } u = { };
11 // CHECK: @u2 = global %1 { i32 0, [4 x i8] undef }
12 union { int i; double f; } u2 = { };
14 // CHECK: @u3 = global %2 zeroinitializer
15 union { double f; int i; } u3 = { };
17 // CHECK: @b = global [2 x i32] [i32 0, i32 22]
18 int b[2] = {
19 [1] = 22
22 // PR6955
24 struct ds {
25 struct {
26 struct {
27 short a;
29 short b;
30 struct {
31 short c;
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 %3 { %4 { %struct.anon zeroinitializer, i16 0, %struct.anon { 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 %3 { %4 { %struct.anon { i16 2 }, i16 3, %struct.anon zeroinitializer } }
47 struct ds ds7 = {
48 { {
49 .a = 1
50 } },
51 .a = 2,
52 .b = 3
55 void test1(int argc, char **argv)
57 // CHECK: internal global %struct.foo { i8* null, i32 1024 }
58 static struct foo foo = {
59 .b = 1024,
62 // CHECK: bitcast %union.anon* %u2
63 // CHECK: call void @llvm.memset
64 union { int i; float f; } u2 = { };
66 // CHECK-NOT: call void @llvm.memset
67 union { int i; float f; } u3;
69 // CHECK: ret void
73 // PR7151
74 struct S {
75 int nkeys;
76 int *keys;
77 union {
78 void *data;
82 void test2() {
83 struct S *btkr;
85 *btkr = (struct S) {
86 .keys = 0,
87 { .data = 0 },