Chris Lattner | 6538347 | 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 | d880363 | 2008-08-10 01:58:45 +0000 | [diff] [blame] | 5 | static int y = sizeof(x); // expected-error {{not a compile-time constant}} |
Chris Lattner | 6538347 | 2007-12-18 07:15:40 +0000 | [diff] [blame] | 6 | } |
| 7 | |
Eli Friedman | b0c0554 | 2008-05-21 05:06:46 +0000 | [diff] [blame] | 8 | // PR2347 |
| 9 | void f (unsigned int m) |
| 10 | { |
Eli Friedman | 6b2564c | 2008-05-21 05:37:55 +0000 | [diff] [blame] | 11 | int e[2][m]; |
Eli Friedman | b0c0554 | 2008-05-21 05:06:46 +0000 | [diff] [blame] | 12 | |
| 13 | e[0][0] = 0; |
| 14 | } |
| 15 | |
Chris Lattner | 67027a7 | 2008-11-12 21:25:45 +0000 | [diff] [blame] | 16 | // PR3048 |
Chris Lattner | 0947b4e | 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 | 67027a7 | 2008-11-12 21:25:45 +0000 | [diff] [blame] | 18 | |
Anders Carlsson | 96e05bc | 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; |
Chris Lattner | 211316f | 2008-12-07 00:59:53 +0000 | [diff] [blame] | 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}} |
Anders Carlsson | 96e05bc | 2008-12-07 00:20:55 +0000 | [diff] [blame] | 32 | |
Chris Lattner | 211316f | 2008-12-07 00:59:53 +0000 | [diff] [blame] | 33 | int (*e)[i]; // expected-error {{variably modified type declaration not allowed at file scope}} |
Anders Carlsson | 96e05bc | 2008-12-07 00:20:55 +0000 | [diff] [blame] | 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 | |