Document gcov-io (PR gcov-profile/84735).
[official-gcc.git] / gcc / testsuite / gcc.dg / c99-const-expr-6.c
blobca602438d35c6f8c9435c7bfb574ad1b77ddace3
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" } */
7 /* PR 29116. */
8 int n = 0, p[n * 0 + 1]; /* { dg-error "variabl" } */
10 /* PR 31871. */
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
28 are required. */
30 struct s {
31 int a : (n * 0 + 1); /* { dg-error "constant" } */
34 enum e {
35 E = (1 + ((__INTPTR_TYPE__) (void *) 0)), /* { dg-error "constant" } */
36 E2 = 0
39 enum f {
40 F = (1 ? 1 : n), /* { dg-error "constant" } */
41 F2 = 0
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. */
47 enum g {
48 G = (1 ? 1 : (int){0}), /* { dg-error "constant" } */
49 G2 = 0
52 int v[2] = { [(n * 0 + 1)] = 1 }; /* { dg-error "constant|near initialization" } */
54 void
55 f (int a)
57 switch (a)
59 case (n * 0 + 1): /* { dg-error "constant" } */