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 | |
Sebastian Redl | 3cb0692 | 2009-02-07 19:52:04 +0000 | [diff] [blame] | 3 | struct s; // expected-note 2 {{forward declaration of 'struct s'}} |
Chris Lattner | 5265af5 | 2007-07-19 00:42:40 +0000 | [diff] [blame] | 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 | |
Douglas Gregor | 0bfe54f | 2009-02-10 21:49:46 +0000 | [diff] [blame^] | 23 | struct vari *func(struct vari a[]) { // expected-warning {{'struct vari' may not be used as an array element due to flexible array member}} |
Steve Naroff | 26b8ff4 | 2007-08-26 14:38:38 +0000 | [diff] [blame] | 24 | return a; |
| 25 | } |
| 26 | |
Steve Naroff | 9a75f8a | 2008-01-18 20:40:52 +0000 | [diff] [blame] | 27 | int foo[](void); // expected-error {{'foo' declared as array of functions}} |
Steve Naroff | d3cd1e5 | 2008-01-18 00:39:39 +0000 | [diff] [blame] | 28 | int foo2[1](void); // expected-error {{'foo2' declared as array of functions}} |
Steve Naroff | 26b8ff4 | 2007-08-26 14:38:38 +0000 | [diff] [blame] | 29 | |
| 30 | typedef int (*pfunc)(void); |
| 31 | |
| 32 | pfunc xx(int f[](void)) { // expected-error {{'f' declared as array of functions}} |
| 33 | return f; |
| 34 | } |
Steve Naroff | 42471f8 | 2007-08-30 22:35:45 +0000 | [diff] [blame] | 35 | |
| 36 | void check_size() { |
| 37 | float f; |
| 38 | int size_not_int[f]; // expected-error {{size of array has non-integer type 'float'}} |
| 39 | int negative_size[1-2]; // expected-error{{array size is negative}} |
| 40 | int zero_size[0]; // expected-warning{{zero size arrays are an extension}} |
| 41 | } |
| 42 | |
Steve Naroff | d7444aa | 2007-08-31 17:20:07 +0000 | [diff] [blame] | 43 | static int I; |
Chris Lattner | 211316f | 2008-12-07 00:59:53 +0000 | [diff] [blame] | 44 | typedef int TA[I]; // expected-error {{variable length array declaration not allowed at file scope}} |
Steve Naroff | d7444aa | 2007-08-31 17:20:07 +0000 | [diff] [blame] | 45 | |
| 46 | void strFunc(char *); |
| 47 | const char staticAry[] = "test"; |
| 48 | int checkStaticAry() { |
Chris Lattner | 5cf216b | 2008-01-04 18:04:52 +0000 | [diff] [blame] | 49 | strFunc(staticAry); // expected-warning{{passing 'char const [5]' discards qualifiers, expected 'char *'}} |
Steve Naroff | d7444aa | 2007-08-31 17:20:07 +0000 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | |