blob: 4b7a746b463fb116ade8055d5c8a3d661edb66fd [file] [log] [blame]
Chris Lattner65383472007-12-18 07:15:40 +00001// RUN: clang %s -verify -fsyntax-only
2
3int test1() {
4 typedef int x[test1()]; // vla
Chris Lattnerd8803632008-08-10 01:58:45 +00005 static int y = sizeof(x); // expected-error {{not a compile-time constant}}
Chris Lattner65383472007-12-18 07:15:40 +00006}
7
Eli Friedmanb0c05542008-05-21 05:06:46 +00008// PR2347
9void f (unsigned int m)
10{
Eli Friedman6b2564c2008-05-21 05:37:55 +000011 int e[2][m];
Eli Friedmanb0c05542008-05-21 05:06:46 +000012
13 e[0][0] = 0;
14}
15
Chris Lattner67027a72008-11-12 21:25:45 +000016// PR3048
Chris Lattner0947b4e2008-11-24 01:28:17 +000017int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}}
Chris Lattner67027a72008-11-12 21:25:45 +000018
Anders Carlsson96e05bc2008-12-07 00:20:55 +000019// PR2352
20void f2(unsigned int m)
21{
22 extern int e[2][m]; // expected-error {{variable length array declaration can not have 'extern' linkage}}
23
24 e[0][0] = 0;
25
26}
27
28// PR2361
29int i;
Chris Lattner211316f2008-12-07 00:59:53 +000030int 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}}
Anders Carlsson96e05bc2008-12-07 00:20:55 +000032
Chris Lattner211316f2008-12-07 00:59:53 +000033int (*e)[i]; // expected-error {{variably modified type declaration not allowed at file scope}}
Anders Carlsson96e05bc2008-12-07 00:20:55 +000034
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 (*c)[i]; // expected-error {{variably modified type declaration can not have 'extern' linkage}}
41 static int (*d)[i];
42}
43