annotate gcc/testsuite/gcc.dg/gnu99-const-expr-4.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* Test for constant expressions: cases involving VLAs and typeof, at
kono
parents:
diff changeset
2 file scope. */
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=gnu99 -pedantic-errors" } */
kono
parents:
diff changeset
6
kono
parents:
diff changeset
7 /* It appears address constants may contain casts to variably modified
kono
parents:
diff changeset
8 types. Whether they should be permitted was discussed in
kono
parents:
diff changeset
9 <http://groups.google.com/group/comp.std.c/msg/923eee5ab690fd98>
kono
parents:
diff changeset
10 <LV7g2Vy3ARF$Ew9Q@romana.davros.org>; since static pointers to VLAs
kono
parents:
diff changeset
11 are definitely permitted within functions and may be initialized
kono
parents:
diff changeset
12 and such initialization involves implicit conversion to a variably
kono
parents:
diff changeset
13 modified type, allowing explicit casts seems appropriate. Thus,
kono
parents:
diff changeset
14 GCC allows them as long as the "evaluated" size expressions do not
kono
parents:
diff changeset
15 contain the various operators not permitted to be evaluated in a
kono
parents:
diff changeset
16 constant expression, and as long as the result is genuinely
kono
parents:
diff changeset
17 constant (meaning that pointer arithmetic using the size of the VLA
kono
parents:
diff changeset
18 is generally not permitted). */
kono
parents:
diff changeset
19
kono
parents:
diff changeset
20 static int sa[100];
kono
parents:
diff changeset
21 int m;
kono
parents:
diff changeset
22 int n;
kono
parents:
diff changeset
23
kono
parents:
diff changeset
24 static int (*a1)[] = &sa;
kono
parents:
diff changeset
25 static int (*a2)[] = (__typeof__(int (*)[n]))sa;
kono
parents:
diff changeset
26 static int (*a4)[] = (__typeof__((int (*)[n])sa))sa;
kono
parents:
diff changeset
27 static int (*a5)[] = (__typeof__((int (*)[m++])sa))sa; /* { dg-error "constant" } */
kono
parents:
diff changeset
28 static int (*a6)[] = (__typeof__((int (*)[100])(int (*)[m++])sa))sa;
kono
parents:
diff changeset
29 static int (*a7)[] = (__typeof__((int (*)[n])sa + m++))sa; /* { dg-error "constant" } */