1 // RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic
4 typedef int x[test1()]; // vla
5 static int y = sizeof(x); // expected-error {{not a compile-time constant}}
9 void f (unsigned int m)
17 int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}}
20 void f2(unsigned int m)
22 extern int e1[2][m]; // expected-error {{variable length array declaration cannot have 'extern' linkage}}
30 int c[][i]; // expected-error {{variably modified type declaration not allowed at file scope}}
31 int d[i]; // expected-error {{variable length array declaration not allowed at file scope}}
33 int (*e)[i]; // expected-error {{variably modified type declaration not allowed at file scope}}
37 static int a[i]; // expected-error {{variable length array declaration cannot have 'static' storage duration}}
38 extern int b[i]; // expected-error {{variable length array declaration cannot have 'extern' linkage}}
40 extern int (*c1)[i]; // expected-error {{variably modified type declaration cannot have 'extern' linkage}}
45 static const unsigned array[((2 * (int)((((4) / 2) + 1.0/3.0) * (4) - 1e-8)) + 1)]; // expected-warning {{variable length array folded to constant array as an extension}}
47 int a[*]; // expected-error {{star modifier used outside of function prototype}}
51 int pr2044(int b) {int (*c(void))[b];**c() = 2;} // expected-error {{variably modified type}}
53 int (*pr2044c(void))[pr2044b]; // expected-error {{variably modified type}}
56 void f5() { char a[][f5_ci] = {""}; } // expected-warning {{variable length array folded to constant array as an extension}}
59 void pr5185(int a[*]);
60 void pr5185(int a[*]) // expected-error {{variable length array must be bound in function definition}}
64 void pr23151(int (*p1)[*]) // expected-error {{variable length array must be bound in function definition}}
67 // Make sure this isn't treated as an error
68 int TransformBug(int a) {
69 return sizeof(*(int(*)[({ goto v; v: a;})]) 0); // expected-warning {{use of GNU statement expression extension}}
74 int a[ // expected-error {{variable length array in struct}}
75 implicitly_declared() // expected-warning {{implicit declaration}}
78 int (*use_implicitly_declared)() = implicitly_declared; // ok, was implicitly declared at file scope
80 void VLAPtrAssign(int size) {
81 int array[1][2][3][size][4][5];
82 // This is well formed
83 int (*p)[2][3][size][4][5] = array;
84 // Last array dimension too large
85 int (*p2)[2][3][size][4][6] = array; // expected-warning {{incompatible pointer types}}
86 // Second array dimension too large
87 int (*p3)[20][3][size][4][5] = array; // expected-warning {{incompatible pointer types}}
89 // Not illegal in C, program _might_ be well formed if size == 3.
90 int (*p4)[2][size][3][4][5] = array;