Chris Lattner | 4ef8dd6 | 2007-11-01 02:45:17 +0000 | [diff] [blame] | 1 | // RUN: clang %s -verify -fsyntax-only |
| 2 | |
| 3 | typedef void (* fp)(void); |
| 4 | void foo(void); |
| 5 | fp a[1] = { foo }; |
| 6 | |
Chris Lattner | 4cc6271 | 2007-11-27 21:35:27 +0000 | [diff] [blame] | 7 | int myArray[5] = {1, 2, 3, 4, 5}; |
| 8 | int *myPointer2 = myArray; |
| 9 | int *myPointer = &(myArray[2]); |
| 10 | |
Chris Lattner | d411e04 | 2007-12-02 07:47:49 +0000 | [diff] [blame] | 11 | |
| 12 | extern int x; |
| 13 | void *g = &x; |
| 14 | int *h = &x; |
| 15 | |
Eli Friedman | a312ce2 | 2008-02-08 00:48:24 +0000 | [diff] [blame] | 16 | int test() { |
| 17 | int a[10]; |
| 18 | int b[10] = a; // expected-error {{initialization with "{...}" expected}} |
| 19 | } |
Chris Lattner | be34ac6 | 2008-05-04 01:13:36 +0000 | [diff] [blame] | 20 | |
| 21 | |
| 22 | // PR2050 |
| 23 | struct cdiff_cmd { |
| 24 | const char *name; |
| 25 | unsigned short argc; |
| 26 | int (*handler)(); |
| 27 | }; |
| 28 | int cdiff_cmd_open(); |
| 29 | struct cdiff_cmd commands[] = { |
| 30 | {"OPEN", 1, &cdiff_cmd_open } |
| 31 | }; |
| 32 | |
Eli Friedman | 97c0a39 | 2008-05-21 03:39:11 +0000 | [diff] [blame] | 33 | // PR2348 |
| 34 | static struct { int z; } s[2]; |
| 35 | int *t = &(*s).z; |
| 36 | |
| 37 | // PR2349 |
| 38 | short *a2(void) |
| 39 | { |
| 40 | short int b; |
| 41 | static short *bp = &b; // expected-error {{initializer element is not constant}} |
| 42 | |
| 43 | return bp; |
| 44 | } |
Eli Friedman | f8f873d | 2008-05-30 18:07:22 +0000 | [diff] [blame^] | 45 | |
| 46 | int pbool(void) { |
| 47 | typedef const _Bool cbool; |
| 48 | _Bool pbool1 = (void *) 0; |
| 49 | cbool pbool2 = &pbool; |
| 50 | return pbool2; |
| 51 | } |
| 52 | |