Eli Friedman | 4efaa27 | 2008-11-12 09:44:48 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | |
| 3 | #define EVAL_EXPR(testno, expr) int test##testno = sizeof(struct{char qq[expr];}); |
| 4 | int x; |
| 5 | EVAL_EXPR(1, (_Bool)&x) |
| 6 | EVAL_EXPR(2, (int)(1.0+(double)4)) |
| 7 | EVAL_EXPR(3, (int)(1.0+(float)4.0)) |
| 8 | EVAL_EXPR(4, (_Bool)(1 ? (void*)&x : 0)) |
| 9 | EVAL_EXPR(5, (_Bool)(int[]){0}) |
| 10 | struct y {int x,y;}; |
| 11 | EVAL_EXPR(6, (int)(1+(struct y*)0)) |
| 12 | EVAL_EXPR(7, (int)&((struct y*)0)->y) |
| 13 | EVAL_EXPR(8, (_Bool)"asdf") |
Eli Friedman | a6afa76 | 2008-11-13 06:09:17 +0000 | [diff] [blame] | 14 | EVAL_EXPR(9, !!&x) |
| 15 | EVAL_EXPR(10, ((void)1, 12)) |
| 16 | void g0(void); |
| 17 | EVAL_EXPR(11, (g0(), 12)) // FIXME: This should give an error |
| 18 | EVAL_EXPR(12, 1.0&&2.0) |
| 19 | EVAL_EXPR(13, x || 3.0) |
Anders Carlsson | 4bbc0e0 | 2008-11-24 04:21:33 +0000 | [diff] [blame] | 20 | |
| 21 | unsigned int l_19 = 1; |
| 22 | EVAL_EXPR(14, (1 ^ l_19) && 1); // expected-error {{fields must have a constant size}} |
Anders Carlsson | 35873c4 | 2008-11-24 04:41:22 +0000 | [diff] [blame] | 23 | |
| 24 | void f() |
| 25 | { |
| 26 | int a; |
| 27 | EVAL_EXPR(15, (_Bool)&a); // expected-error {{fields must have a constant size}} |
| 28 | } |