i-c-e.c revision 42b83dde7c700b34f9435ad746984169888ae705
1// 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
10// __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
23
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
49