array-constraint.c revision a41a8c5972c2632247ae7913cf6ce65d45f7e702
1// RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s 2 3struct s; // expected-note 2 {{forward declaration of 'struct s'}} 4struct s* t (struct s z[]) { // expected-error {{array has incomplete element type}} 5 return z; 6} 7 8void ff() { 9 struct s v, *p; // expected-error {{variable has incomplete type 'struct s'}} 10 11 p = &v; 12} 13 14void *k (void l[2]) { // expected-error {{array has incomplete element type}} 15 return l; 16} 17 18struct vari { 19 int a; 20 int b[]; 21}; 22 23struct vari *func(struct vari a[]) { // expected-warning {{'struct vari' may not be used as an array element due to flexible array member}} 24 return a; 25} 26 27int foo[](void); // expected-error {{'foo' declared as array of functions}} 28int foo2[1](void); // expected-error {{'foo2' declared as array of functions}} 29 30typedef int (*pfunc)(void); 31 32pfunc xx(int f[](void)) { // expected-error {{'f' declared as array of functions}} 33 return f; 34} 35 36void 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 43static int I; 44typedef int TA[I]; // expected-error {{variable length array declaration not allowed at file scope}} 45 46void strFunc(char *); // expected-note{{passing argument to parameter here}} 47const char staticAry[] = "test"; 48void checkStaticAry() { 49 strFunc(staticAry); // expected-warning{{passing 'char const [5]' to parameter of type 'char *' discards qualifiers}} 50} 51 52 53