annotate gcc/testsuite/gcc.dg/c90-const-expr-6.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test for constant expressions: operands and casts not permitted in
kono
parents:
diff changeset
2 integer constant expressions. */
kono
parents:
diff changeset
3 /* Origin: Joseph Myers <joseph@codesourcery.com> */
kono
parents:
diff changeset
4 /* { dg-do compile } */
kono
parents:
diff changeset
5 /* { dg-options "-std=iso9899:1990 -pedantic-errors" } */
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 __extension__ typedef __INTPTR_TYPE__ intptr_t;
kono
parents:
diff changeset
8
kono
parents:
diff changeset
9 /* PR 29116. */
kono
parents:
diff changeset
10 int n = 0, p[n * 0 + 1]; /* { dg-error "variabl|can't be evaluated" } */
kono
parents:
diff changeset
11
kono
parents:
diff changeset
12 /* PR 31871. */
kono
parents:
diff changeset
13 extern int c[1 + ((intptr_t) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
kono
parents:
diff changeset
14
kono
parents:
diff changeset
15 /* Implicit conversions from floating-point constants are not OK,
kono
parents:
diff changeset
16 although explicit ones are. */
kono
parents:
diff changeset
17 extern int c1[1.0 ? 1 : 0]; /* { dg-error "variab|can't be evaluated" } */
kono
parents:
diff changeset
18
kono
parents:
diff changeset
19 extern int c2[(int)1.0 ? 1 : 0];
kono
parents:
diff changeset
20
kono
parents:
diff changeset
21 extern int c3[1.0 && 1]; /* { dg-error "variab|can't be evaluated" } */
kono
parents:
diff changeset
22
kono
parents:
diff changeset
23 extern int c4[(int)1.0 && 1];
kono
parents:
diff changeset
24
kono
parents:
diff changeset
25 extern int c5[1.0 || 1]; /* { dg-error "variab|can't be evaluated" } */
kono
parents:
diff changeset
26
kono
parents:
diff changeset
27 extern int c6[(int)1.0 || 1];
kono
parents:
diff changeset
28
kono
parents:
diff changeset
29 /* Similar with various other cases where integer constant expressions
kono
parents:
diff changeset
30 are required. */
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 struct s {
kono
parents:
diff changeset
33 int a : (n * 0 + 1); /* { dg-error "constant" } */
kono
parents:
diff changeset
34 };
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 enum e {
kono
parents:
diff changeset
37 E = (1 + ((intptr_t) (void *) 0)), /* { dg-error "constant" } */
kono
parents:
diff changeset
38 E2 = 0
kono
parents:
diff changeset
39 };
kono
parents:
diff changeset
40
kono
parents:
diff changeset
41 enum f {
kono
parents:
diff changeset
42 F = (1 ? 1 : n), /* { dg-error "constant" } */
kono
parents:
diff changeset
43 F2 = 0
kono
parents:
diff changeset
44 };
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 void
kono
parents:
diff changeset
47 f (int a)
kono
parents:
diff changeset
48 {
kono
parents:
diff changeset
49 int v[1 + ((intptr_t) (void *) 0)]; /* { dg-error "variab|can't be evaluated" } */
kono
parents:
diff changeset
50 switch (a)
kono
parents:
diff changeset
51 {
kono
parents:
diff changeset
52 case (n * 0 + 1): /* { dg-error "constant" } */
kono
parents:
diff changeset
53 ;
kono
parents:
diff changeset
54 }
kono
parents:
diff changeset
55 }