2018-05-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / vla-12.c
blob604ea88dc2c72c15560cc9c34f3a6736093d8899
1 /* Test for typeof evaluation: should be at the appropriate point in
2 the containing expression rather than just adding a statement. */
3 /* Origin: Joseph Myers <joseph@codesourcery.com> */
4 /* { dg-do run } */
5 /* { dg-options "-std=gnu99" } */
7 extern void exit (int);
8 extern void abort (void);
10 void *p;
12 void
13 f1 (void)
15 int i = 0, j = -1, k = -1;
16 /* typeof applied to expression with cast. */
17 (j = ++i), (void)(typeof ((int (*)[(k = ++i)])p))p;
18 if (j != 1 || k != 2 || i != 2)
19 abort ();
22 void
23 f2 (void)
25 int i = 0, j = -1, k = -1;
26 /* typeof applied to type. */
27 (j = ++i), (void)(typeof (int (*)[(k = ++i)]))p;
28 if (j != 1 || k != 2 || i != 2)
29 abort ();
32 void
33 f3 (void)
35 int i = 0, j = -1, k = -1;
36 void *q;
37 /* typeof applied to expression with cast that is used. */
38 (j = ++i), (void)((typeof (1 + (int (*)[(k = ++i)])p))p);
39 if (j != 1 || k != 2 || i != 2)
40 abort ();
43 int
44 main (void)
46 f1 ();
47 f2 ();
48 f3 ();
49 exit (0);