[Reland][Runtimes] Merge 'compile_commands.json' files from runtimes build (#116303)
[llvm-project.git] / clang / test / Sema / array-constraint.c
blob099f38bbb1587906fa731b98d1cbffd1a1ae0e00
1 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
3 struct s; // expected-note 2 {{forward declaration of 'struct s'}}
4 struct s* t (struct s z[]) { // expected-error {{array has incomplete element type}}
5 return z;
8 void ff(void) {
9 struct s v, *p; // expected-error {{variable has incomplete type 'struct s'}}
11 p = &v;
14 void *k (void l[2]) { // expected-error {{array has incomplete element type}}
15 return l;
18 struct vari {
19 int a;
20 int b[];
23 struct 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;
27 int foo[](void); // expected-error {{'foo' declared as array of functions}}
28 int foo2[1](void); // expected-error {{'foo2' declared as array of functions}}
30 typedef int (*pfunc)(void);
32 pfunc xx(int f[](void)) { // expected-error {{'f' declared as array of functions}}
33 return f;
36 void check_size(void) {
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 with a negative size}}
40 int zero_size[0]; // expected-warning{{zero size arrays are an extension}}
43 static int I;
44 typedef int TA[I]; // expected-error {{variable length array declaration not allowed at file scope}}
46 void strFunc(char *); // expected-note{{passing argument to parameter here}}
47 const char staticAry[] = "test";
48 void checkStaticAry(void) {
49 strFunc(staticAry); // expected-warning{{passing 'const char[5]' to parameter of type 'char *' discards qualifiers}}