2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
|
2007-07-19 08:42:40 +08:00
|
|
|
|
2009-02-08 03:52:04 +08:00
|
|
|
struct s; // expected-note 2 {{forward declaration of 'struct s'}}
|
2007-07-19 08:42:40 +08:00
|
|
|
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[];
|
|
|
|
};
|
|
|
|
|
2009-02-11 05:49:46 +08:00
|
|
|
struct vari *func(struct vari a[]) { // expected-warning {{'struct vari' may not be used as an array element due to flexible array member}}
|
2007-08-26 22:38:38 +08:00
|
|
|
return a;
|
|
|
|
}
|
|
|
|
|
2008-01-19 04:40:52 +08:00
|
|
|
int foo[](void); // expected-error {{'foo' declared as array of functions}}
|
2008-01-18 08:39:39 +08:00
|
|
|
int foo2[1](void); // expected-error {{'foo2' declared as array of functions}}
|
2007-08-26 22:38:38 +08:00
|
|
|
|
|
|
|
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'}}
|
2011-01-04 12:44:35 +08:00
|
|
|
int negative_size[1-2]; // expected-error{{array with a negative size}}
|
2007-08-31 06:35:45 +08:00
|
|
|
int zero_size[0]; // expected-warning{{zero size arrays are an extension}}
|
|
|
|
}
|
|
|
|
|
2007-09-01 01:20:07 +08:00
|
|
|
static int I;
|
2008-12-07 08:59:53 +08:00
|
|
|
typedef int TA[I]; // expected-error {{variable length array declaration not allowed at file scope}}
|
2007-09-01 01:20:07 +08:00
|
|
|
|
2010-04-22 08:20:18 +08:00
|
|
|
void strFunc(char *); // expected-note{{passing argument to parameter here}}
|
2007-09-01 01:20:07 +08:00
|
|
|
const char staticAry[] = "test";
|
2009-07-22 08:43:08 +08:00
|
|
|
void checkStaticAry() {
|
2010-09-05 08:04:01 +08:00
|
|
|
strFunc(staticAry); // expected-warning{{passing 'const char [5]' to parameter of type 'char *' discards qualifiers}}
|
2007-09-01 01:20:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|