File: gnu90-const-expr-1.c

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (56 lines) | stat: -rw-r--r-- 2,562 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* Test for constant expressions: GNU extensions.  */
/* Origin: Joseph Myers <joseph@codesourcery.com> */
/* { dg-do compile } */
/* { dg-options "-std=gnu90 -pedantic-errors" } */

int n;

void
f (void)
{
  int i = 0;
  int a[n]; /* { dg-error "ISO C90 forbids variable length array" } */
  enum e1 {
    /* Integer constant expressions may not contain statement
       expressions (not a permitted operand).  */
    E1 = (1 ? 0 : ({ 0; })), /* { dg-error "constant expression" } */
    /* { dg-error "ISO C forbids braced-groups" "ISO" { target *-*-* } .-1 } */
    /* Real and imaginary parts act like other arithmetic
       operators.  */
    E2 = __real__ (1 ? 0 : i++), /* { dg-error "constant expression" } */
    E3 = __real__ 0,
    E4 = __imag__ (1 ? 0 : i++), /* { dg-error "constant" } */
    E5 = __imag__ 0,
    /* __alignof__ always constant.  */
    E6 = __alignof__ (int[n]), /* { dg-error "ISO C90 forbids variable length array" } */
    E7 = __alignof__ (a),
    /* __extension__ ignored for constant expression purposes.  */
    E8 = __extension__ (1 ? 0 : i++), /* { dg-error "constant expression" } */
    E9 = __extension__ 0,
    /* Conditional expressions with omitted arguments act like the
       standard type.  */ 
    E10 = (1 ? : i++), /* { dg-error "constant expression" } */
    /* { dg-error "ISO C forbids omitting" "ISO" { target *-*-* } .-1 } */
    E11 = (1 ? : 0) /* { dg-error "ISO C forbids omitting" } */
  };
  enum e2 {
    /* Complex integer constants may be cast directly to integer
       types, but not after further arithmetic on them.  */
    F1 = (int) (_Complex int) 2i, /* { dg-error "constant expression" } */
    /* { dg-error "complex" "complex" { target *-*-* } .-1 } */
    /* { dg-error "imaginary" "imaginary" { target *-*-* } .-2 } */
    F2 = (int) +2i, /* { dg-error "constant expression" } */
    /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */
    F3 = (int) (1 + 2i), /* { dg-error "constant expression" } */
    /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */
    F4 = (int) 2i /* { dg-error "imaginary" } */
  };
  static double dr = __real__ (1.0 + 2.0i);
  /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */
  static double di = __imag__ (1.0 + 2.0i);
  /* { dg-error "imaginary" "ISO" { target *-*-* } .-1 } */
  /* Statement expressions allowed in unevaluated subexpressions in
     initializers in gnu99 but not gnu89.  */
  static int j = (1 ? 0 : ({ 0; })); /* { dg-error "constant expression" } */
  /* { dg-error "braced" "ISO" { target *-*-* } .-1 } */
}