annotate gcc/testsuite/gcc.dg/c99-const-expr-12.c @ 111:04ced10e8804

gcc 7
author kono
date Fri, 27 Oct 2017 22:46:09 +0900
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test for constant expressions: VLA size constraints. */
kono
parents:
diff changeset
2 /* Origin: Joseph Myers <joseph@codesourcery.com> */
kono
parents:
diff changeset
3 /* { dg-do compile } */
kono
parents:
diff changeset
4 /* { dg-options "-std=iso9899:1999 -pedantic-errors" } */
kono
parents:
diff changeset
5
kono
parents:
diff changeset
6 void
kono
parents:
diff changeset
7 f (int m)
kono
parents:
diff changeset
8 {
kono
parents:
diff changeset
9 /* An array size that is a constant expression, not just an integer
kono
parents:
diff changeset
10 constant expression, must be checked for being positive, but only
kono
parents:
diff changeset
11 an integer constant expression makes it not a VLA (which affects
kono
parents:
diff changeset
12 certain compatibility checks, in particular). */
kono
parents:
diff changeset
13 int a1[0]; /* { dg-error "zero" } */
kono
parents:
diff changeset
14 int a2[-1]; /* { dg-error "negative" } */
kono
parents:
diff changeset
15 int a3[(int)(double)0.0]; /* { dg-error "zero" } */
kono
parents:
diff changeset
16 int a4[(int)-1.0]; /* { dg-error "negative" } */
kono
parents:
diff changeset
17 int a5[(int)+1.0];
kono
parents:
diff changeset
18 int a6[(int)+2.0];
kono
parents:
diff changeset
19 void *p = (m ? &a5 : &a6);
kono
parents:
diff changeset
20 int a7[(int)1.0];
kono
parents:
diff changeset
21 int a8[(int)2.0];
kono
parents:
diff changeset
22 void *q = (m ? &a7 : &a8); /* { dg-error "pointer type mismatch in conditional expression" } */
kono
parents:
diff changeset
23 }