1 // RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
2 
3 void f1() {
4   // Scalars in braces.
5   int a = { 1 };
6 }
7 
8 void f2() {
9   int a[2][2] = { { 1, 2 }, { 3, 4 } };
10   int b[3][3] = { { 1, 2 }, { 3, 4 } };
11   int *c[2] = { &a[1][1], &b[2][2] };
12   int *d[2][2] = { {&a[1][1], &b[2][2]}, {&a[0][0], &b[1][1]} };
13   int *e[3][3] = { {&a[1][1], &b[2][2]}, {&a[0][0], &b[1][1]} };
14   char ext[3][3] = {".Y",".U",".V"};
15 }
16 
17 typedef void (* F)(void);
18 extern void foo(void);
19 struct S { F f; };
20 void f3() {
21   struct S a[1] = { { foo } };
22 }
23 
24 // Constants
25 // CHECK: @g3 = constant i32 10
26 // CHECK: @f4.g4 = internal constant i32 12
27 const int g3 = 10;
28 int f4() {
29   static const int g4 = 12;
30   return g4;
31 }
32 
33 // PR6537
34 typedef union vec3 {
35   struct { double x, y, z; };
36   double component[3];
37 } vec3;
38 vec3 f5(vec3 value) {
39   return (vec3) {{
40     .x = value.x
41   }};
42 }
43 
44 // rdar://problem/8154689
45 void f6() {
46   int x;
47   long ids[] = { (long) &x };
48 }
49 
50 
51 
52 
53 // CHECK: @test7 = global{{.*}}{ i32 0, [4 x i8] c"bar\00" }
54 // PR8217
55 struct a7 {
56   int  b;
57   char v[];
58 };
59 
60 struct a7 test7 = { .b = 0, .v = "bar" };
61 
62 
63 // PR279 comment #3
64 char test8(int X) {
65   char str[100000] = "abc"; // tail should be memset.
66   return str[X];
67 // CHECK: @test8(
68 // CHECK: call void @llvm.memset
69 // CHECK: store i8 97
70 // CHECK: store i8 98
71 // CHECK: store i8 99
72 }
73