vla.c revision 88f7b576dde22ca95b4c73c4fd463e2e799873a7
1// RUN: clang-cc %s -verify -fsyntax-only -pedantic 2 3int test1() { 4 typedef int x[test1()]; // vla 5 static int y = sizeof(x); // expected-error {{not a compile-time constant}} 6} 7 8// PR2347 9void f (unsigned int m) 10{ 11 int e[2][m]; 12 13 e[0][0] = 0; 14} 15 16// PR3048 17int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}} 18 19// PR2352 20void f2(unsigned int m) 21{ 22 extern int e1[2][m]; // expected-error {{variable length array declaration can not have 'extern' linkage}} 23 24 e1[0][0] = 0; 25 26} 27 28// PR2361 29int i; 30int c[][i]; // expected-error {{variably modified type declaration not allowed at file scope}} 31int d[i]; // expected-error {{variable length array declaration not allowed at file scope}} 32 33int (*e)[i]; // expected-error {{variably modified type declaration not allowed at file scope}} 34 35void f3() 36{ 37 static int a[i]; // expected-error {{variable length array declaration can not have 'static' storage duration}} 38 extern int b[i]; // expected-error {{variable length array declaration can not have 'extern' linkage}} 39 40 extern int (*c1)[i]; // expected-error {{variably modified type declaration can not have 'extern' linkage}} 41 static int (*d)[i]; 42} 43 44// PR3663 45static const unsigned array[((2 * (int)((((4) / 2) + 1.0/3.0) * (4) - 1e-8)) + 1)]; // expected-warning {{size of static array must be an integer constant expression}} 46 47int a[*]; // expected-error {{star modifier used outside of function prototype}} 48int f4(int a[*][*]); 49 50// PR2044 51int pr2044(int b) {int (*c(void))[b];**c() = 2;} // expected-error {{variably modified type}} 52int pr2044b; 53int (*pr2044c(void))[pr2044b]; // expected-error {{variably modified type}} 54