blob: 8fa840d4654a2d311329b719320df70ea4620881 [file] [log] [blame]
Chris Lattner04de9932008-12-12 07:01:24 +00001// RUN: clang %s -fsyntax-only -verify -pedantic -fpascal-strings
2
3int a() {int p; *(1 ? &p : (void*)(0 && (a(),1))) = 10;}
4
5// rdar://6091492 - ?: with __builtin_constant_p as the operand is an i-c-e.
6int expr;
7char w[__builtin_constant_p(expr) ? expr : 1];
8
9
Chris Lattner42b83dd2008-12-12 18:00:51 +000010// __builtin_constant_p as the condition of ?: allows arbitrary foldable
11// constants to be transmogrified into i-c-e's.
12char b[__builtin_constant_p((int)(1.0+2.0)) ? (int)(1.0+2.0) : -1];
13
14struct c {
15 int a : ( // expected-error {{expression is not an integer constant expression}}
16 __builtin_constant_p((int)(1.0+2.0)) ? (int)(1.0+
17 expr // expected-note {{subexpression not valid in an integer constant expression}}
18 ) : -1);
19};
20
21
22
Chris Lattner04de9932008-12-12 07:01:24 +000023
24void test1(int n, int* p) { *(n ? p : (void *)(7-7)) = 1; }
25void test2(int n, int* p) { *(n ? p : (void *)0) = 1; }
26
27
28
29char array[1024/(sizeof (long))];
30
31int x['\xBb' == (char) 187 ? 1: -1];
32
33// PR1992
34void func(int x)
35{
36 switch (x) {
37 case sizeof("abc"): break;
38 case sizeof("loooong"): func(4);
39 case sizeof("\ploooong"): func(4);
40 }
41}
42
43
44// rdar://4213768
45int expr;
46char y[__builtin_constant_p(expr) ? -1 : 1];
47char z[__builtin_constant_p(4) ? 1 : -1];
48