annotate gcc/testsuite/gcc.dg/gnu90-const-expr-1.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test for constant expressions: GNU extensions. */
kono
parents:
diff changeset
2 /* Origin: Joseph Myers <joseph@codesourcery.com> */
kono
parents:
diff changeset
3 /* { dg-do compile } */
kono
parents:
diff changeset
4 /* { dg-options "-std=gnu90 -pedantic-errors" } */
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 int n;
kono
parents:
diff changeset
7
kono
parents:
diff changeset
8 void
kono
parents:
diff changeset
9 f (void)
kono
parents:
diff changeset
10 {
kono
parents:
diff changeset
11 int i = 0;
kono
parents:
diff changeset
12 int a[n]; /* { dg-error "ISO C90 forbids variable length array" } */
kono
parents:
diff changeset
13 enum e1 {
kono
parents:
diff changeset
14 /* Integer constant expressions may not contain statement
kono
parents:
diff changeset
15 expressions (not a permitted operand). */
kono
parents:
diff changeset
16 E1 = (1 ? 0 : ({ 0; })), /* { dg-error "constant expression" } */
kono
parents:
diff changeset
17 /* { dg-error "ISO C forbids braced-groups" "ISO" { target *-*-* } .-1 } */
kono
parents:
diff changeset
18 /* Real and imaginary parts act like other arithmetic
kono
parents:
diff changeset
19 operators. */
kono
parents:
diff changeset
20 E2 = __real__ (1 ? 0 : i++), /* { dg-error "constant expression" } */
kono
parents:
diff changeset
21 E3 = __real__ 0,
kono
parents:
diff changeset
22 E4 = __imag__ (1 ? 0 : i++), /* { dg-error "constant" } */
kono
parents:
diff changeset
23 E5 = __imag__ 0,
kono
parents:
diff changeset
24 /* __alignof__ always constant. */
kono
parents:
diff changeset
25 E6 = __alignof__ (int[n]), /* { dg-error "ISO C90 forbids variable length array" } */
kono
parents:
diff changeset
26 E7 = __alignof__ (a),
kono
parents:
diff changeset
27 /* __extension__ ignored for constant expression purposes. */
kono
parents:
diff changeset
28 E8 = __extension__ (1 ? 0 : i++), /* { dg-error "constant expression" } */
kono
parents:
diff changeset
29 E9 = __extension__ 0,
kono
parents:
diff changeset
30 /* Conditional expressions with omitted arguments act like the
kono
parents:
diff changeset
31 standard type. */
kono
parents:
diff changeset
32 E10 = (1 ? : i++), /* { dg-error "constant expression" } */
kono
parents:
diff changeset
33 /* { dg-error "ISO C forbids omitting" "ISO" { target *-*-* } .-1 } */
kono
parents:
diff changeset
34 E11 = (1 ? : 0) /* { dg-error "ISO C forbids omitting" } */
kono
parents:
diff changeset
35 };
kono
parents:
diff changeset
36 enum e2 {
kono
parents:
diff changeset
37 /* Complex integer constants may be cast directly to integer
kono
parents:
diff changeset
38 types, but not after further arithmetic on them. */
kono
parents:
diff changeset
39 F1 = (int) (_Complex int) 2i, /* { dg-error "constant expression" } */
kono
parents:
diff changeset
40 /* { dg-error "complex" "complex" { target *-*-* } .-1 } */
kono
parents:
diff changeset
41 /* { dg-error "imaginary" "imaginary" { target *-*-* } .-2 } */
kono
parents:
diff changeset
42 F2 = (int) +2i, /* { dg-error "constant expression" } */
kono
parents:
diff changeset
43 /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */
kono
parents:
diff changeset
44 F3 = (int) (1 + 2i), /* { dg-error "constant expression" } */
kono
parents:
diff changeset
45 /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */
kono
parents:
diff changeset
46 F4 = (int) 2i /* { dg-error "imaginary" } */
kono
parents:
diff changeset
47 };
kono
parents:
diff changeset
48 static double dr = __real__ (1.0 + 2.0i);
kono
parents:
diff changeset
49 /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */
kono
parents:
diff changeset
50 static double di = __imag__ (1.0 + 2.0i);
kono
parents:
diff changeset
51 /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */
kono
parents:
diff changeset
52 /* Statement expressions allowed in unevaluated subexpressions in
kono
parents:
diff changeset
53 initializers in gnu99 but not gnu89. */
kono
parents:
diff changeset
54 static int j = (1 ? 0 : ({ 0; })); /* { dg-error "constant expression" } */
kono
parents:
diff changeset
55 /* { dg-error "braced" "ISO" { target *-*-* } .-1 } */
kono
parents:
diff changeset
56 }