1 /* { dg-do run } */
2 /* { dg-options "-std=c99 -pedantic-errors" } */
3 /* { dg-require-effective-target alloca } */
4 /* PR c/18740 */
5
6 static int i;
7
foo(int n)8 int foo(int n)
9 {
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;
37 }
38
foo6(int a,int b[a][a],int (* c)[sizeof (* b)])39 int foo6(int a, int b[a][a], int (*c)[sizeof(*b)]) {
40 return sizeof (*c);
41 }
42
main()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);
49 }
50