1 /* Test for constant expressions: GNU extensions. */
2 /* Origin: Joseph Myers <joseph@codesourcery.com> */
3 /* { dg-do compile } */
4 /* { dg-options "-std=gnu99" } */
14 /* Integer constant expressions may not contain statement
15 expressions (not a permitted operand). */
16 E1 = (1 ? 0 : ({ 0; })), /* { dg-error "constant" } */
17 /* Real and imaginary parts act like other arithmetic
19 E2 = __real__ (1 ? 0 : i++), /* { dg-error "constant" } */
21 E4 = __imag__ (1 ? 0 : i++), /* { dg-error "constant" } */
23 /* __alignof__ always constant. */
24 E6 = __alignof__ (int[n]),
26 /* __extension__ ignored for constant expression purposes. */
27 E8 = __extension__ (1 ? 0 : i++), /* { dg-error "constant" } */
29 /* Conditional expressions with omitted arguments act like the
31 E10 = (1 ? : i++), /* { dg-error "constant" } */
35 /* Complex integer constants may be cast directly to integer
36 types, but not after further arithmetic on them. */
37 F1 = (int) (_Complex int) 2i, /* { dg-error "constant" } */
38 F2 = (int) +2i, /* { dg-error "constant" } */
39 F3 = (int) (1 + 2i), /* { dg-error "constant" } */
42 static double dr = __real__ (1.0 + 2.0i);
43 static double di = __imag__ (1.0 + 2.0i);
44 /* Statement expressions allowed in unevaluated subexpressions in
45 initializers in gnu99 but not gnu89. */
46 static int j = (1 ? 0 : ({ 0; }));