diff options
author | ed <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
---|---|---|
committer | ed <ed@FreeBSD.org> | 2009-06-02 17:58:47 +0000 |
commit | f27e5a09a0d815b8a4814152954ff87dadfdefc0 (patch) | |
tree | ce7d964cbb5e39695b71481698f10cb099c23d4a /test/Sema/vla.c | |
download | FreeBSD-src-f27e5a09a0d815b8a4814152954ff87dadfdefc0.zip FreeBSD-src-f27e5a09a0d815b8a4814152954ff87dadfdefc0.tar.gz |
Import Clang, at r72732.
Diffstat (limited to 'test/Sema/vla.c')
-rw-r--r-- | test/Sema/vla.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/test/Sema/vla.c b/test/Sema/vla.c new file mode 100644 index 0000000..70ba08b --- /dev/null +++ b/test/Sema/vla.c @@ -0,0 +1,56 @@ +// RUN: clang-cc %s -verify -fsyntax-only -pedantic + +int test1() { + typedef int x[test1()]; // vla + static int y = sizeof(x); // expected-error {{not a compile-time constant}} +} + +// PR2347 +void f (unsigned int m) +{ + int e[2][m]; + + e[0][0] = 0; +} + +// PR3048 +int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}} + +// PR2352 +void f2(unsigned int m) +{ + extern int e1[2][m]; // expected-error {{variable length array declaration can not have 'extern' linkage}} + + e1[0][0] = 0; + +} + +// PR2361 +int i; +int c[][i]; // expected-error {{variably modified type declaration not allowed at file scope}} +int d[i]; // expected-error {{variable length array declaration not allowed at file scope}} + +int (*e)[i]; // expected-error {{variably modified type declaration not allowed at file scope}} + +void f3() +{ + static int a[i]; // expected-error {{variable length array declaration can not have 'static' storage duration}} + extern int b[i]; // expected-error {{variable length array declaration can not have 'extern' linkage}} + + extern int (*c1)[i]; // expected-error {{variably modified type declaration can not have 'extern' linkage}} + static int (*d)[i]; +} + +// PR3663 +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}} + +int a[*]; // expected-error {{star modifier used outside of function prototype}} +int f4(int a[*][*]); + +// PR2044 +int pr2044(int b) {int (*c(void))[b];**c() = 2;} // expected-error {{variably modified type}} +int pr2044b; +int (*pr2044c(void))[pr2044b]; // expected-error {{variably modified type}} + +const int f5_ci = 1; +void f5() { char a[][f5_ci] = {""}; } // expected-error {{variable-sized object may not be initialized}} |