| 1 |
/* Test for modifying and taking addresses of compound literals whose |
| 2 |
variably modified types involve typeof. */ |
| 3 |
/* Origin: Joseph Myers <[email protected]> */ |
| 4 |
/* { dg-do run } */ |
| 5 |
/* { dg-options "-std=gnu99" } */ |
| 6 |
|
| 7 |
#include <stdarg.h> |
| 8 |
|
| 9 |
extern void exit (int); |
| 10 |
extern void abort (void); |
| 11 |
|
| 12 |
int a[1]; |
| 13 |
|
| 14 |
void |
| 15 |
f1 (void) |
| 16 |
{ |
| 17 |
int i = 0; |
| 18 |
int (**p)[1] = &(typeof (++i, (int (*)[i])a)){&a}; |
| 19 |
if (*p != &a) |
| 20 |
abort (); |
| 21 |
if (i != 1) |
| 22 |
abort (); |
| 23 |
} |
| 24 |
|
| 25 |
void |
| 26 |
f2 (void) |
| 27 |
{ |
| 28 |
int i = 0; |
| 29 |
(typeof (++i, (int (*)[i])a)){&a} = 0; |
| 30 |
if (i != 1) |
| 31 |
abort (); |
| 32 |
} |
| 33 |
|
| 34 |
void |
| 35 |
f3 (void) |
| 36 |
{ |
| 37 |
int i = 0; |
| 38 |
(typeof (++i, (int (*)[i])a)){&a} += 1; |
| 39 |
if (i != 1) |
| 40 |
abort (); |
| 41 |
} |
| 42 |
|
| 43 |
void |
| 44 |
f4 (void) |
| 45 |
{ |
| 46 |
int i = 0; |
| 47 |
--(typeof (++i, (int (*)[i])a)){&a + 1}; |
| 48 |
if (i != 1) |
| 49 |
abort (); |
| 50 |
} |
| 51 |
|
| 52 |
void |
| 53 |
f5 (void) |
| 54 |
{ |
| 55 |
int i = 0; |
| 56 |
(typeof (++i, (int (*)[i])a)){&a}++; |
| 57 |
if (i != 1) |
| 58 |
abort (); |
| 59 |
} |
| 60 |
|
| 61 |
int |
| 62 |
main (void) |
| 63 |
{ |
| 64 |
f1 (); |
| 65 |
f2 (); |
| 66 |
f3 (); |
| 67 |
f4 (); |
| 68 |
f5 (); |
| 69 |
exit (0); |
| 70 |
} |