1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
2*67e74705SXin Li // REQUIRES: LP64
3*67e74705SXin Li
4*67e74705SXin Li struct foo { int a, b; };
5*67e74705SXin Li
6*67e74705SXin Li static struct foo t = (struct foo){0,0};
7*67e74705SXin Li static struct foo t1 = __builtin_choose_expr(0, (struct foo){0,0}, (struct foo){0,0});
8*67e74705SXin Li static struct foo t2 = {0,0};
9*67e74705SXin Li static struct foo t3 = t2; // expected-error {{initializer element is not a compile-time constant}}
10*67e74705SXin Li static int *p = (int []){2,4};
11*67e74705SXin Li static int x = (int){1};
12*67e74705SXin Li
13*67e74705SXin Li static int *p2 = (int []){2,x}; // expected-error {{initializer element is not a compile-time constant}}
14*67e74705SXin Li static long *p3 = (long []){2,"x"}; // expected-warning {{incompatible pointer to integer conversion initializing 'long' with an expression of type 'char [2]'}}
15*67e74705SXin Li
16*67e74705SXin Li typedef struct { } cache_t; // expected-warning{{empty struct is a GNU extension}}
17*67e74705SXin Li static cache_t clo_I1_cache = ((cache_t) { } ); // expected-warning{{use of GNU empty initializer extension}}
18*67e74705SXin Li
19*67e74705SXin Li typedef struct Test {int a;int b;} Test;
20*67e74705SXin Li static Test* ll = &(Test) {0,0};
21*67e74705SXin Li
22*67e74705SXin Li extern void fooFunc(struct foo *pfoo);
23*67e74705SXin Li
main(int argc,char ** argv)24*67e74705SXin Li int main(int argc, char **argv) {
25*67e74705SXin Li int *l = (int []){x, *p, *p2};
26*67e74705SXin Li fooFunc(&(struct foo){ 1, 2 });
27*67e74705SXin Li }
28*67e74705SXin Li
29*67e74705SXin Li struct Incomplete; // expected-note{{forward declaration of 'struct Incomplete'}}
30*67e74705SXin Li struct Incomplete* I1 = &(struct Incomplete){1, 2, 3}; // expected-error {{variable has incomplete type}}
IncompleteFunc(unsigned x)31*67e74705SXin Li void IncompleteFunc(unsigned x) {
32*67e74705SXin Li struct Incomplete* I2 = (struct foo[x]){1, 2, 3}; // expected-error {{variable-sized object may not be initialized}}
33*67e74705SXin Li (void){1,2,3}; // expected-error {{variable has incomplete type}}
34*67e74705SXin Li (void(void)) { 0 }; // expected-error{{illegal initializer type 'void (void)'}}
35*67e74705SXin Li }
36*67e74705SXin Li
37*67e74705SXin Li // PR6080
38*67e74705SXin Li int array[(sizeof(int[3]) == sizeof( (int[]) {0,1,2} )) ? 1 : -1];
39