URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Go to most recent revision |
Details |
Compare with Previous |
View Log
Line No. |
Rev |
Author |
Line |
1 |
689 |
jeremybenn |
/* Test for constant expressions: cases involving VLAs and typeof, at
|
2 |
|
|
file scope. */
|
3 |
|
|
/* Origin: Joseph Myers <joseph@codesourcery.com> */
|
4 |
|
|
/* { dg-do compile } */
|
5 |
|
|
/* { dg-options "-std=gnu99 -pedantic-errors" } */
|
6 |
|
|
|
7 |
|
|
/* It appears address constants may contain casts to variably modified
|
8 |
|
|
types. Whether they should be permitted was discussed in
|
9 |
|
|
<http://groups.google.com/group/comp.std.c/msg/923eee5ab690fd98>
|
10 |
|
|
<LV7g2Vy3ARF$Ew9Q@romana.davros.org>; since static pointers to VLAs
|
11 |
|
|
are definitely permitted within functions and may be initialized
|
12 |
|
|
and such initialization involves implicit conversion to a variably
|
13 |
|
|
modified type, allowing explicit casts seems appropriate. Thus,
|
14 |
|
|
GCC allows them as long as the "evaluated" size expressions do not
|
15 |
|
|
contain the various operators not permitted to be evaluated in a
|
16 |
|
|
constant expression, and as long as the result is genuinely
|
17 |
|
|
constant (meaning that pointer arithmetic using the size of the VLA
|
18 |
|
|
is generally not permitted). */
|
19 |
|
|
|
20 |
|
|
static int sa[100];
|
21 |
|
|
int m;
|
22 |
|
|
int n;
|
23 |
|
|
|
24 |
|
|
static int (*a1)[] = &sa;
|
25 |
|
|
static int (*a2)[] = (__typeof__(int (*)[n]))sa;
|
26 |
|
|
static int (*a4)[] = (__typeof__((int (*)[n])sa))sa;
|
27 |
|
|
static int (*a5)[] = (__typeof__((int (*)[m++])sa))sa; /* { dg-error "constant" } */
|
28 |
|
|
static int (*a6)[] = (__typeof__((int (*)[100])(int (*)[m++])sa))sa;
|
29 |
|
|
static int (*a7)[] = (__typeof__((int (*)[n])sa + m++))sa; /* { dg-error "constant" } */
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.