2007-12-18 15:15:40 +08:00
|
|
|
// RUN: clang %s -verify -fsyntax-only
|
|
|
|
|
|
|
|
int test1() {
|
|
|
|
typedef int x[test1()]; // vla
|
2008-08-10 09:58:45 +08:00
|
|
|
static int y = sizeof(x); // expected-error {{not a compile-time constant}}
|
2007-12-18 15:15:40 +08:00
|
|
|
}
|
|
|
|
|
2008-05-21 13:06:46 +08:00
|
|
|
// PR2347
|
|
|
|
void f (unsigned int m)
|
|
|
|
{
|
2008-05-21 13:37:55 +08:00
|
|
|
int e[2][m];
|
2008-05-21 13:06:46 +08:00
|
|
|
|
|
|
|
e[0][0] = 0;
|
|
|
|
}
|
|
|
|
|
2008-11-13 05:25:45 +08:00
|
|
|
// PR3048
|
2008-11-24 09:28:17 +08:00
|
|
|
int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}}
|
2008-11-13 05:25:45 +08:00
|
|
|
|
2008-12-07 08:20:55 +08:00
|
|
|
// PR2352
|
|
|
|
void f2(unsigned int m)
|
|
|
|
{
|
2009-02-25 03:23:27 +08:00
|
|
|
extern int e1[2][m]; // expected-error {{variable length array declaration can not have 'extern' linkage}}
|
2008-12-07 08:20:55 +08:00
|
|
|
|
2009-02-25 03:23:27 +08:00
|
|
|
e1[0][0] = 0;
|
2008-12-07 08:20:55 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// PR2361
|
|
|
|
int i;
|
2008-12-07 08:59:53 +08:00
|
|
|
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}}
|
2008-12-07 08:20:55 +08:00
|
|
|
|
2008-12-07 08:59:53 +08:00
|
|
|
int (*e)[i]; // expected-error {{variably modified type declaration not allowed at file scope}}
|
2008-12-07 08:20:55 +08:00
|
|
|
|
|
|
|
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}}
|
|
|
|
|
2009-02-25 03:23:27 +08:00
|
|
|
extern int (*c1)[i]; // expected-error {{variably modified type declaration can not have 'extern' linkage}}
|
2008-12-07 08:20:55 +08:00
|
|
|
static int (*d)[i];
|
|
|
|
}
|
|
|
|
|