Chris Lattner | 3b427b3 | 2007-10-11 00:18:28 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify -pedantic %s |
Chris Lattner | 5265af5 | 2007-07-19 00:42:40 +0000 | [diff] [blame] | 2 | |
| 3 | struct s; |
| 4 | struct s* t (struct s z[]) { // expected-error {{array has incomplete element type}} |
Chris Lattner | ce7f4cc | 2007-08-26 06:48:28 +0000 | [diff] [blame] | 5 | return z; |
Chris Lattner | 5265af5 | 2007-07-19 00:42:40 +0000 | [diff] [blame] | 6 | } |
| 7 | |
Steve Naroff | 53a3234 | 2007-08-28 18:45:29 +0000 | [diff] [blame] | 8 | void ff() { |
| 9 | struct s v, *p; // expected-error {{variable has incomplete type 'struct s'}} |
| 10 | |
| 11 | p = &v; |
| 12 | } |
| 13 | |
Chris Lattner | 5265af5 | 2007-07-19 00:42:40 +0000 | [diff] [blame] | 14 | void *k (void l[2]) { // expected-error {{array has incomplete element type}} |
| 15 | return l; |
| 16 | } |
| 17 | |
Steve Naroff | 26b8ff4 | 2007-08-26 14:38:38 +0000 | [diff] [blame] | 18 | struct vari { |
| 19 | int a; |
| 20 | int b[]; |
| 21 | }; |
| 22 | |
| 23 | struct vari *func(struct vari a[]) { // expected-error {{'struct vari' may not be used as an array element due to flexible array member}} |
| 24 | return a; |
| 25 | } |
| 26 | |
| 27 | int foo[](void); // expected-error {{'foo' declared as array of functions}} |
| 28 | |
| 29 | typedef int (*pfunc)(void); |
| 30 | |
| 31 | pfunc xx(int f[](void)) { // expected-error {{'f' declared as array of functions}} |
| 32 | return f; |
| 33 | } |
Steve Naroff | 42471f8 | 2007-08-30 22:35:45 +0000 | [diff] [blame] | 34 | |
| 35 | void check_size() { |
| 36 | float f; |
| 37 | int size_not_int[f]; // expected-error {{size of array has non-integer type 'float'}} |
| 38 | int negative_size[1-2]; // expected-error{{array size is negative}} |
| 39 | int zero_size[0]; // expected-warning{{zero size arrays are an extension}} |
| 40 | } |
| 41 | |
Steve Naroff | d7444aa | 2007-08-31 17:20:07 +0000 | [diff] [blame] | 42 | static int I; |
| 43 | typedef int TA[I]; // expected-error {{variable length array declared outside of any function}} |
| 44 | |
| 45 | void strFunc(char *); |
| 46 | const char staticAry[] = "test"; |
| 47 | int checkStaticAry() { |
| 48 | strFunc(staticAry); // expected-warning{{passing 'char const []' to 'char *' discards qualifiers}} |
| 49 | } |
| 50 | |
| 51 | |