Add include needed for MSVC.
[clang/acc.git] / test / Sema / vla.c
blob70ba08b7eb0a8a973bec50a39b4fc068b692a346
1 // RUN: clang-cc %s -verify -fsyntax-only -pedantic
3 int test1() {
4 typedef int x[test1()]; // vla
5 static int y = sizeof(x); // expected-error {{not a compile-time constant}}
8 // PR2347
9 void f (unsigned int m)
11 int e[2][m];
13 e[0][0] = 0;
16 // PR3048
17 int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}}
19 // PR2352
20 void f2(unsigned int m)
22 extern int e1[2][m]; // expected-error {{variable length array declaration can not have 'extern' linkage}}
24 e1[0][0] = 0;
28 // PR2361
29 int i;
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}}
35 void f3()
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}}
40 extern int (*c1)[i]; // expected-error {{variably modified type declaration can not have 'extern' linkage}}
41 static int (*d)[i];
44 // PR3663
45 static 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}}
47 int a[*]; // expected-error {{star modifier used outside of function prototype}}
48 int f4(int a[*][*]);
50 // PR2044
51 int pr2044(int b) {int (*c(void))[b];**c() = 2;} // expected-error {{variably modified type}}
52 int pr2044b;
53 int (*pr2044c(void))[pr2044b]; // expected-error {{variably modified type}}
55 const int f5_ci = 1;
56 void f5() { char a[][f5_ci] = {""}; } // expected-error {{variable-sized object may not be initialized}}