1 // RUN: %clang_cc1 %s -verify -fsyntax-only -ffreestanding
6 typedef void (* fp
)(void);
10 fp a
[(short int)1] = { foo
};
12 int myArray
[5] = {1, 2, 3, 4, 5};
13 int *myPointer2
= myArray
;
14 int *myPointer
= &(myArray
[2]);
23 int b
[10] = a
; // expected-error {{array initializer must be an initializer list}}
24 int +; // expected-error {{expected identifier or '('}}
35 struct cdiff_cmd commands
[] = {
36 {"OPEN", 1, &cdiff_cmd_open
}
40 static struct { int z
; } s
[2];
47 static short *bp
= &b
; // expected-error {{initializer element is not a compile-time constant}}
53 typedef const _Bool cbool
;
54 _Bool pbool1
= (void *) 0;
55 cbool pbool2
= &pbool
;
61 union { float f
; unsigned u
; } u
= { 1.0f
};
64 int f3(int x
) { return x
; }
65 typedef void (*vfunc
)(void);
66 void *bar
= (vfunc
) f3
;
72 int sym_fw1a_scr
[] = {
73 ((int)(&((struct sym_reg
*)0)->nc_gpreg
)) & 0,
74 8 * ((int)(&((struct sym_reg
*)0)->nc_gpreg
))
78 struct s1 s2
= { // expected-error {{variable has incomplete type 'struct s1'}} \
79 // expected-note {{forward declaration of 'struct s1'}}
80 .a
= sizeof(struct s3
), // expected-error {{invalid application of 'sizeof'}} \
81 // expected-note{{forward declaration of 'struct s3'}}
82 .b
= bogus
// expected-error {{use of undeclared identifier 'bogus'}}
88 // <rdar://problem/6094855>
89 typedef struct { } empty
;
98 // <rdar://problem/6096826>
110 struct foo2 bar2
[] = {
114 struct foo2 bar3
= { 1, 2 }; // expected-warning{{excess elements in struct initializer}}
116 int* ptest1
= __builtin_choose_expr(1, (int*)0, (int*)0);
118 typedef int32_t ivector4
__attribute((vector_size(16)));
119 ivector4 vtest1
= 1 ? (ivector4
){1} : (ivector4
){1};
120 ivector4 vtest2
= __builtin_choose_expr(1, (ivector4
){1}, (ivector4
){1});
122 uintptr_t ptrasintadd1
= (uintptr_t)&a
- 4;
123 uintptr_t ptrasintadd2
= (uintptr_t)&a
+ 4;
124 uintptr_t ptrasintadd3
= 4 + (uintptr_t)&a
;
127 const wchar_t widestr
[] = L
"asdf";
130 const double pr5447
= (0.05 < -1.0) ? -1.0 : 0.0499878;
134 // None of these are constant initializers, but we implement GCC's old
135 // behaviour of accepting bar and zed but not foo. GCC's behaviour was
136 // changed in 2007 (rev 122551), so we should be able to change too one
139 int PR4386_foo() __attribute((weak
));
142 int PR4386_a
= ((void *) PR4386_bar
) != 0;
143 int PR4386_b
= ((void *) PR4386_foo
) != 0; // expected-error{{initializer element is not a compile-time constant}}
144 int PR4386_c
= ((void *) PR4386_zed
) != 0;
145 int PR4386_zed() __attribute((weak
));