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; |
Chris Lattner | d880363 | 2008-08-10 01:58:45 +0000 | [diff] [blame] | 41 | static short *bp = &b; // expected-error {{initializer element is not a compile-time constant}} |
Eli Friedman | 97c0a39 | 2008-05-21 03:39:11 +0000 | [diff] [blame] | 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 | |
Chris Lattner | d5bac57 | 2008-08-19 00:58:40 +0000 | [diff] [blame] | 53 | |
| 54 | // rdar://5870981 |
| 55 | union { float f; unsigned u; } u = { 1.0f }; |
| 56 | |
Daniel Dunbar | 1e465df | 2008-08-25 20:08:27 +0000 | [diff] [blame] | 57 | // rdar://6156694 |
| 58 | int f3(int x) { return x; } |
| 59 | typedef void (*vfunc)(void); |
| 60 | void *bar = (vfunc) f3; |
Eli Friedman | b529d83 | 2008-09-02 09:37:00 +0000 | [diff] [blame^] | 61 | |
| 62 | // PR2747 |
| 63 | struct sym_reg { |
| 64 | char nc_gpreg; |
| 65 | }; |
| 66 | int sym_fw1a_scr[] = { |
| 67 | ((int)(&((struct sym_reg *)0)->nc_gpreg)) & 0 |
| 68 | }; |