blob: d48e723c58a1af115a062cafa114533d01cea4fc [file] [log] [blame]
Nuno Lopesa75b71f2010-04-18 19:06:43 +00001// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s
Daniel Dunbare4c92382009-02-13 22:58:39 +00002
Lauro Ramos Venancio305762c2008-02-18 22:44:02 +00003void f1() {
4 // Scalars in braces.
5 int a = { 1 };
Lauro Ramos Venancio305762c2008-02-18 22:44:02 +00006}
7
8void 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]} };
Lauro Ramos Venancio145cd892008-02-19 19:27:31 +000014 char ext[3][3] = {".Y",".U",".V"};
Anders Carlssona3881fc2008-01-29 01:28:48 +000015}
Chris Lattnerd3c38562008-05-04 00:56:25 +000016
17typedef void (* F)(void);
18extern void foo(void);
19struct S { F f; };
20void f3() {
21 struct S a[1] = { { foo } };
22}
23
Daniel Dunbare4c92382009-02-13 22:58:39 +000024// Constants
Nuno Lopesa75b71f2010-04-18 19:06:43 +000025// CHECK: @g3 = constant i32 10
26// CHECK: @f4.g4 = internal constant i32 12
Daniel Dunbare4c92382009-02-13 22:58:39 +000027const int g3 = 10;
28int f4() {
29 static const int g4 = 12;
30 return g4;
31}
Chris Lattnerb35baae2010-03-08 21:08:07 +000032
33// PR6537
34typedef union vec3 {
35 struct { double x, y, z; };
36 double component[3];
37} vec3;
38vec3 f5(vec3 value) {
39 return (vec3) {{
40 .x = value.x
41 }};
42}