init.c revision 1e465df22f312a3661d70fc15b1a55dc97ebfce8
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}} 19} 20 21 22// PR2050 23struct cdiff_cmd { 24 const char *name; 25 unsigned short argc; 26 int (*handler)(); 27}; 28int cdiff_cmd_open(); 29struct cdiff_cmd commands[] = { 30 {"OPEN", 1, &cdiff_cmd_open } 31}; 32 33// PR2348 34static struct { int z; } s[2]; 35int *t = &(*s).z; 36 37// PR2349 38short *a2(void) 39{ 40 short int b; 41 static short *bp = &b; // expected-error {{initializer element is not a compile-time constant}} 42 43 return bp; 44} 45 46int pbool(void) { 47 typedef const _Bool cbool; 48 _Bool pbool1 = (void *) 0; 49 cbool pbool2 = &pbool; 50 return pbool2; 51} 52 53 54// rdar://5870981 55union { float f; unsigned u; } u = { 1.0f }; 56 57// rdar://6156694 58int f3(int x) { return x; } 59typedef void (*vfunc)(void); 60void *bar = (vfunc) f3; 61