1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -verify -fsyntax-only -pedantic 2*f4a2713aSLionel Sambuc test1()3*f4a2713aSLionel Sambucint test1() { 4*f4a2713aSLionel Sambuc typedef int x[test1()]; // vla 5*f4a2713aSLionel Sambuc static int y = sizeof(x); // expected-error {{not a compile-time constant}} 6*f4a2713aSLionel Sambuc } 7*f4a2713aSLionel Sambuc 8*f4a2713aSLionel Sambuc // PR2347 f(unsigned int m)9*f4a2713aSLionel Sambucvoid f (unsigned int m) 10*f4a2713aSLionel Sambuc { 11*f4a2713aSLionel Sambuc int e[2][m]; 12*f4a2713aSLionel Sambuc 13*f4a2713aSLionel Sambuc e[0][0] = 0; 14*f4a2713aSLionel Sambuc } 15*f4a2713aSLionel Sambuc 16*f4a2713aSLionel Sambuc // PR3048 17*f4a2713aSLionel Sambuc int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}} 18*f4a2713aSLionel Sambuc 19*f4a2713aSLionel Sambuc // PR2352 f2(unsigned int m)20*f4a2713aSLionel Sambucvoid f2(unsigned int m) 21*f4a2713aSLionel Sambuc { 22*f4a2713aSLionel Sambuc extern int e1[2][m]; // expected-error {{variable length array declaration cannot have 'extern' linkage}} 23*f4a2713aSLionel Sambuc 24*f4a2713aSLionel Sambuc e1[0][0] = 0; 25*f4a2713aSLionel Sambuc 26*f4a2713aSLionel Sambuc } 27*f4a2713aSLionel Sambuc 28*f4a2713aSLionel Sambuc // PR2361 29*f4a2713aSLionel Sambuc int i; 30*f4a2713aSLionel Sambuc int c[][i]; // expected-error {{variably modified type declaration not allowed at file scope}} 31*f4a2713aSLionel Sambuc int d[i]; // expected-error {{variable length array declaration not allowed at file scope}} 32*f4a2713aSLionel Sambuc 33*f4a2713aSLionel Sambuc int (*e)[i]; // expected-error {{variably modified type declaration not allowed at file scope}} 34*f4a2713aSLionel Sambuc f3()35*f4a2713aSLionel Sambucvoid f3() 36*f4a2713aSLionel Sambuc { 37*f4a2713aSLionel Sambuc static int a[i]; // expected-error {{variable length array declaration cannot have 'static' storage duration}} 38*f4a2713aSLionel Sambuc extern int b[i]; // expected-error {{variable length array declaration cannot have 'extern' linkage}} 39*f4a2713aSLionel Sambuc 40*f4a2713aSLionel Sambuc extern int (*c1)[i]; // expected-error {{variably modified type declaration cannot have 'extern' linkage}} 41*f4a2713aSLionel Sambuc static int (*d)[i]; 42*f4a2713aSLionel Sambuc } 43*f4a2713aSLionel Sambuc 44*f4a2713aSLionel Sambuc // PR3663 45*f4a2713aSLionel Sambuc 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}} 46*f4a2713aSLionel Sambuc 47*f4a2713aSLionel Sambuc int a[*]; // expected-error {{star modifier used outside of function prototype}} 48*f4a2713aSLionel Sambuc int f4(int a[*][*]); 49*f4a2713aSLionel Sambuc 50*f4a2713aSLionel Sambuc // PR2044 pr2044(int b)51*f4a2713aSLionel Sambucint pr2044(int b) {int (*c(void))[b];**c() = 2;} // expected-error {{variably modified type}} 52*f4a2713aSLionel Sambuc int pr2044b; 53*f4a2713aSLionel Sambuc int (*pr2044c(void))[pr2044b]; // expected-error {{variably modified type}} 54*f4a2713aSLionel Sambuc 55*f4a2713aSLionel Sambuc const int f5_ci = 1; f5()56*f4a2713aSLionel Sambucvoid f5() { char a[][f5_ci] = {""}; } // expected-warning {{variable length array folded to constant array as an extension}} 57*f4a2713aSLionel Sambuc 58*f4a2713aSLionel Sambuc // PR5185 59*f4a2713aSLionel Sambuc void pr5185(int a[*]); pr5185(int a[* ])60*f4a2713aSLionel Sambucvoid pr5185(int a[*]) // expected-error {{variable length array must be bound in function definition}} 61*f4a2713aSLionel Sambuc { 62*f4a2713aSLionel Sambuc } 63*f4a2713aSLionel Sambuc 64*f4a2713aSLionel Sambuc // Make sure this isn't treated as an error TransformBug(int a)65*f4a2713aSLionel Sambucint TransformBug(int a) { 66*f4a2713aSLionel Sambuc return sizeof(*(int(*)[({ goto v; v: a;})]) 0); // expected-warning {{use of GNU statement expression extension}} 67*f4a2713aSLionel Sambuc } 68