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" } */
8 int n = 0, p[n * 0 + 1]; /* { dg-error "variabl|can't be evaluated" } */
11 extern int c[1 + ((__PTRDIFF_TYPE__) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
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|can't be evaluated" } */
17 extern int c2[(int)1.0 ? 1 : 0];
19 extern int c3[1.0 && 1]; /* { dg-error "variab|can't be evaluated" } */
21 extern int c4[(int)1.0 && 1];
23 extern int c5[1.0 || 1]; /* { dg-error "variab|can't be evaluated" } */
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 + ((__PTRDIFF_TYPE__) (void *) 0)), /* { dg-error "constant" } */
40 F = (1 ? 1 : n), /* { dg-error "constant" } */
47 int v[1 + ((__PTRDIFF_TYPE__) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
50 case (n * 0 + 1): /* { dg-error "constant" } */