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:1990 -pedantic-errors" } */
7 __extension__ typedef __INTPTR_TYPE__ intptr_t;
10 int n = 0, p[n * 0 + 1]; /* { dg-error "variabl|can't be evaluated" } */
13 extern int c[1 + ((intptr_t) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
15 /* Implicit conversions from floating-point constants are not OK,
16 although explicit ones are. */
17 extern int c1[1.0 ? 1 : 0]; /* { dg-error "variab|can't be evaluated" } */
19 extern int c2[(int)1.0 ? 1 : 0];
21 extern int c3[1.0 && 1]; /* { dg-error "variab|can't be evaluated" } */
23 extern int c4[(int)1.0 && 1];
25 extern int c5[1.0 || 1]; /* { dg-error "variab|can't be evaluated" } */
27 extern int c6[(int)1.0 || 1];
29 /* Similar with various other cases where integer constant expressions
33 int a : (n * 0 + 1); /* { dg-error "constant" } */
37 E = (1 + ((intptr_t) (void *) 0)), /* { dg-error "constant" } */
42 F = (1 ? 1 : n), /* { dg-error "constant" } */
49 int v[1 + ((intptr_t) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
52 case (n * 0 + 1): /* { dg-error "constant" } */