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