Chris Lattner | b3ff082 | 2007-12-18 07:15:40 +0000 | [diff] [blame] | 1 | // RUN: clang %s -verify -fsyntax-only |
| 2 | |
| 3 | int test1() { |
| 4 | typedef int x[test1()]; // vla |
Chris Lattner | 1543ae9 | 2008-08-10 01:58:45 +0000 | [diff] [blame] | 5 | static int y = sizeof(x); // expected-error {{not a compile-time constant}} |
Chris Lattner | b3ff082 | 2007-12-18 07:15:40 +0000 | [diff] [blame] | 6 | } |
| 7 | |
Eli Friedman | 19bf5c6 | 2008-05-21 05:06:46 +0000 | [diff] [blame] | 8 | // PR2347 |
| 9 | void f (unsigned int m) |
| 10 | { |
Eli Friedman | 45cd28f | 2008-05-21 05:37:55 +0000 | [diff] [blame] | 11 | int e[2][m]; |
Eli Friedman | 19bf5c6 | 2008-05-21 05:06:46 +0000 | [diff] [blame] | 12 | |
| 13 | e[0][0] = 0; |
| 14 | } |
| 15 | |
Chris Lattner | fa1b4e5 | 2008-11-12 21:25:45 +0000 | [diff] [blame] | 16 | // PR3048 |
Chris Lattner | cc884cc | 2008-11-24 01:28:17 +0000 | [diff] [blame] | 17 | int x = sizeof(struct{char qq[x];}); // expected-error {{fields must have a constant size}} |
Chris Lattner | fa1b4e5 | 2008-11-12 21:25:45 +0000 | [diff] [blame] | 18 | |
Anders Carlsson | 68adbd1 | 2008-12-07 00:20:55 +0000 | [diff] [blame] | 19 | // PR2352 |
| 20 | void 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 |
| 29 | int i; |
| 30 | int c[][i]; // expected-error {{variably modified type declaration not allowed in file scope}} |
| 31 | int d[i]; // expected-error {{variable length array declaration not allowed in file scope}} |
| 32 | |
| 33 | int (*e)[i]; // expected-error {{variably modified type declaration not allowed in file scope}} |
| 34 | |
| 35 | void 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 | |