blob: bee33c09efbd04a30ff7d5da33478acbf3813ca9 [file] [log] [blame]
Daniel Dunbara5728872009-12-15 20:14:24 +00001// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
Chris Lattner5265af52007-07-19 00:42:40 +00002
Sebastian Redl3cb06922009-02-07 19:52:04 +00003struct s; // expected-note 2 {{forward declaration of 'struct s'}}
Chris Lattner5265af52007-07-19 00:42:40 +00004struct s* t (struct s z[]) { // expected-error {{array has incomplete element type}}
Chris Lattnerce7f4cc2007-08-26 06:48:28 +00005 return z;
Chris Lattner5265af52007-07-19 00:42:40 +00006}
7
Steve Naroff53a32342007-08-28 18:45:29 +00008void ff() {
9 struct s v, *p; // expected-error {{variable has incomplete type 'struct s'}}
10
11 p = &v;
12}
13
Chris Lattner5265af52007-07-19 00:42:40 +000014void *k (void l[2]) { // expected-error {{array has incomplete element type}}
15 return l;
16}
17
Steve Naroff26b8ff42007-08-26 14:38:38 +000018struct vari {
19 int a;
20 int b[];
21};
22
Douglas Gregor0bfe54f2009-02-10 21:49:46 +000023struct vari *func(struct vari a[]) { // expected-warning {{'struct vari' may not be used as an array element due to flexible array member}}
Steve Naroff26b8ff42007-08-26 14:38:38 +000024 return a;
25}
26
Steve Naroff9a75f8a2008-01-18 20:40:52 +000027int foo[](void); // expected-error {{'foo' declared as array of functions}}
Steve Naroffd3cd1e52008-01-18 00:39:39 +000028int foo2[1](void); // expected-error {{'foo2' declared as array of functions}}
Steve Naroff26b8ff42007-08-26 14:38:38 +000029
30typedef int (*pfunc)(void);
31
32pfunc xx(int f[](void)) { // expected-error {{'f' declared as array of functions}}
33 return f;
34}
Steve Naroff42471f82007-08-30 22:35:45 +000035
36void check_size() {
37 float f;
38 int size_not_int[f]; // expected-error {{size of array has non-integer type 'float'}}
Chandler Carruthb2b5cc02011-01-04 04:44:35 +000039 int negative_size[1-2]; // expected-error{{array with a negative size}}
Steve Naroff42471f82007-08-30 22:35:45 +000040 int zero_size[0]; // expected-warning{{zero size arrays are an extension}}
41}
42
Steve Naroffd7444aa2007-08-31 17:20:07 +000043static int I;
Chris Lattner211316f2008-12-07 00:59:53 +000044typedef int TA[I]; // expected-error {{variable length array declaration not allowed at file scope}}
Steve Naroffd7444aa2007-08-31 17:20:07 +000045
Douglas Gregora41a8c52010-04-22 00:20:18 +000046void strFunc(char *); // expected-note{{passing argument to parameter here}}
Steve Naroffd7444aa2007-08-31 17:20:07 +000047const char staticAry[] = "test";
Mike Stumpd1969d82009-07-22 00:43:08 +000048void checkStaticAry() {
Chris Lattner58f9e132010-09-05 00:04:01 +000049 strFunc(staticAry); // expected-warning{{passing 'const char [5]' to parameter of type 'char *' discards qualifiers}}
Steve Naroffd7444aa2007-08-31 17:20:07 +000050}
51
52