2007-10-11 08:18:28 +08:00
|
|
|
// RUN: clang -fsyntax-only -verify -pedantic %s
|
2007-07-19 08:42:40 +08:00
|
|
|
|
|
|
|
struct s;
|
|
|
|
struct s* t (struct s z[]) { // expected-error {{array has incomplete element type}}
|
2007-08-26 14:48:28 +08:00
|
|
|
return z;
|
2007-07-19 08:42:40 +08:00
|
|
|
}
|
|
|
|
|
2007-08-29 02:45:29 +08:00
|
|
|
void ff() {
|
|
|
|
struct s v, *p; // expected-error {{variable has incomplete type 'struct s'}}
|
|
|
|
|
|
|
|
p = &v;
|
|
|
|
}
|
|
|
|
|
2007-07-19 08:42:40 +08:00
|
|
|
void *k (void l[2]) { // expected-error {{array has incomplete element type}}
|
|
|
|
return l;
|
|
|
|
}
|
|
|
|
|
2007-08-26 22:38:38 +08:00
|
|
|
struct vari {
|
|
|
|
int a;
|
|
|
|
int b[];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vari *func(struct vari a[]) { // expected-error {{'struct vari' may not be used as an array element due to flexible array member}}
|
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
|
|
|
int foo[](void); // expected-error {{'foo' declared as array of functions}}
|
|
|
|
|
|
|
|
typedef int (*pfunc)(void);
|
|
|
|
|
|
|
|
pfunc xx(int f[](void)) { // expected-error {{'f' declared as array of functions}}
|
|
|
|
return f;
|
|
|
|
}
|
2007-08-31 06:35:45 +08:00
|
|
|
|
|
|
|
void check_size() {
|
|
|
|
float f;
|
|
|
|
int size_not_int[f]; // expected-error {{size of array has non-integer type 'float'}}
|
|
|
|
int negative_size[1-2]; // expected-error{{array size is negative}}
|
|
|
|
int zero_size[0]; // expected-warning{{zero size arrays are an extension}}
|
|
|
|
}
|
|
|
|
|
2007-09-01 01:20:07 +08:00
|
|
|
static int I;
|
|
|
|
typedef int TA[I]; // expected-error {{variable length array declared outside of any function}}
|
|
|
|
|
|
|
|
void strFunc(char *);
|
|
|
|
const char staticAry[] = "test";
|
|
|
|
int checkStaticAry() {
|
2008-01-05 02:04:52 +08:00
|
|
|
strFunc(staticAry); // expected-warning{{passing 'char const [5]' discards qualifiers, expected 'char *'}}
|
2007-09-01 01:20:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|