OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [vla-4.c] - Blame information for rev 816

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 298 jeremybenn
/* { dg-do run } */
2
/* { dg-options "-std=c99 -pedantic-errors" } */
3
/* PR c/18740 */
4
 
5
static int i;
6
 
7
int foo(int n)
8
{
9
  int (*t)[n];
10
  i = 0;
11
  int j = 0;
12
  char b[1][n+3];                       /* Variable length array.  */
13
  int d[3][n];                          /* Variable length array.  */
14
  sizeof (b[i++ + sizeof(j++)]);        /* Outer sizeof is evaluated for vla, but not the inner one.  */
15
  if (i != 1 || j != 0)
16
    return 1;
17
  __typeof__(b[i++]) c1;                /* typeof is evauluated when given a vm */
18
  if (i != 2)
19
    return 1;
20
  __typeof__(t + (i++,0)) c2;            /* typeof is evauluated when given a vm */
21
  if (i != 3)
22
    return 1;
23
  __typeof__(i + (i++,0)) c3;            /* typeof is not evauluated when not given a vm */
24
  if (i != 3)
25
    return 1;
26
  sizeof (d[i++]);                      /* sizeof is evaluated for vla.  */
27
  if (i != 4)
28
    return 1;
29
  __alignof__(__typeof__(t + (i++,0)));  /* typeof is not evauluated when given a vm inside alignof*/
30
  if (i != 4)
31
    return 1;
32
  sizeof(__typeof__(t + (i++,0)));       /* typeof is not evauluated when given a vm inside sizeof*/
33
  if (i != 4)
34
    return 1;
35
  return 0;
36
}
37
 
38
int foo6(int a, int b[a][a], int (*c)[sizeof(*b)]) {
39
  return sizeof (*c);
40
}
41
 
42
int main() {
43
  int b[10][10];
44
  int (*c)[sizeof(int)*10];
45
  if (foo6(10, b, c) != 10*sizeof(int)*sizeof(int))
46
    return 1;
47
  return foo(10);
48
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.