init.c revision 97c0a391138d20e1066174a9cfa92860fb06e5a1
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 constant}}
42
43  return bp;
44}
45