1 /* Test for constant expressions: operands and casts not permitted in
2 integer constant expressions. */
3 /* Origin: Joseph Myers <joseph@codesourcery.com> */
4 /* { dg-do compile } */
5 /* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
8 int n
= 0, p
[n
* 0 + 1]; /* { dg-error "variabl" } */
11 extern int c
[1 + ((__INTPTR_TYPE__
) (void *) 0)]; /* { dg-error "variab" } */
13 /* Implicit conversions from floating-point constants are not OK,
14 although explicit ones are. */
15 extern int c1
[1.0 ? 1 : 0]; /* { dg-error "variab" } */
17 extern int c2
[(int)1.0 ? 1 : 0];
19 extern int c3
[1.0 && 1]; /* { dg-error "variab" } */
21 extern int c4
[(int)1.0 && 1];
23 extern int c5
[1.0 || 1]; /* { dg-error "variab" } */
25 extern int c6
[(int)1.0 || 1];
27 /* Similar with various other cases where integer constant expressions
31 int a
: (n
* 0 + 1); /* { dg-error "constant" } */
35 E
= (1 + ((__INTPTR_TYPE__
) (void *) 0)), /* { dg-error "constant" } */
40 F
= (1 ? 1 : n
), /* { dg-error "constant" } */
44 /* Presume that a compound literal, being a reference to an anonymous
45 variable, is not allowed in an integer constant expression
46 regardless of what initializers it contains. */
48 G
= (1 ? 1 : (int){0}), /* { dg-error "constant" } */
52 int v
[2] = { [(n
* 0 + 1)] = 1 }; /* { dg-error "constant|near initialization" } */
59 case (n
* 0 + 1): /* { dg-error "constant" } */