init.c revision 1f6f54be86a514d531ec231fd837858a43cfe72e
1// RUN: clang %s -verify -fsyntax-only 2 3typedef void (* fp)(void); 4void foo(void); 5fp a[1] = { foo }; 6 7int myArray[5] = {1, 2, 3, 4, 5}; 8int *myPointer2 = myArray; 9int *myPointer = &(myArray[2]); 10 11 12extern int x; 13void *g = &x; 14int *h = &x; 15 16int test() { 17int a[10]; 18int b[10] = a; // expected-error {{initialization with "{...}" expected}} 19int +; // expected-error {{expected identifier or '('}} expected-error {{parse error}} 20} 21 22 23// PR2050 24struct cdiff_cmd { 25 const char *name; 26 unsigned short argc; 27 int (*handler)(); 28}; 29int cdiff_cmd_open(); 30struct cdiff_cmd commands[] = { 31 {"OPEN", 1, &cdiff_cmd_open } 32}; 33 34// PR2348 35static struct { int z; } s[2]; 36int *t = &(*s).z; 37 38// PR2349 39short *a2(void) 40{ 41 short int b; 42 static short *bp = &b; // expected-error {{initializer element is not a compile-time constant}} 43 44 return bp; 45} 46 47int pbool(void) { 48 typedef const _Bool cbool; 49 _Bool pbool1 = (void *) 0; 50 cbool pbool2 = &pbool; 51 return pbool2; 52} 53 54 55// rdar://5870981 56union { float f; unsigned u; } u = { 1.0f }; 57 58// rdar://6156694 59int f3(int x) { return x; } 60typedef void (*vfunc)(void); 61void *bar = (vfunc) f3; 62 63// PR2747 64struct sym_reg { 65 char nc_gpreg; 66}; 67int sym_fw1a_scr[] = { 68 ((int)(&((struct sym_reg *)0)->nc_gpreg)) & 0, 69 8 * ((int)(&((struct sym_reg *)0)->nc_gpreg)) 70}; 71 72// PR3001 73struct s1 s2 = { 74 .a = sizeof(struct s3), // expected-error {{invalid application of 'sizeof'}} 75 .b = bogus // expected-error {{use of undeclared identifier 'bogus'}} 76} 77 78