OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / vla-12.c
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" } */
6
7 extern void exit (int);
8 extern void abort (void);
9
10 void *p;
11
12 void
13 f1 (void)
14 {
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 ();
20 }
21
22 void
23 f2 (void)
24 {
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 ();
30 }
31
32 void
33 f3 (void)
34 {
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 ();
41 }
42
43 int
44 main (void)
45 {
46   f1 ();
47   f2 ();
48   f3 ();
49   exit (0);
50 }