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