| 1 |
extern void abort (void); |
| 2 |
extern void exit (int); |
| 3 |
struct s { unsigned char a[256]; }; |
| 4 |
union u { struct { struct s b; int c; } d; struct { int c; struct s b; } e; }; |
| 5 |
static union u v; |
| 6 |
static union u v0; |
| 7 |
static struct s *p = &v.d.b; |
| 8 |
static struct s *q = &v.e.b; |
| 9 |
|
| 10 |
static inline struct s rp (void) { return *p; } |
| 11 |
static inline struct s rq (void) { return *q; } |
| 12 |
static void pq (void) { *p = rq(); } |
| 13 |
static void qp (void) { *q = rp(); } |
| 14 |
|
| 15 |
static void |
| 16 |
init (struct s *sp) |
| 17 |
{ |
| 18 |
int i; |
| 19 |
for (i = 0; i < 256; i++) |
| 20 |
sp->a[i] = i; |
| 21 |
} |
| 22 |
|
| 23 |
static void |
| 24 |
check (struct s *sp) |
| 25 |
{ |
| 26 |
int i; |
| 27 |
for (i = 0; i < 256; i++) |
| 28 |
if (sp->a[i] != i) |
| 29 |
abort (); |
| 30 |
} |
| 31 |
|
| 32 |
void |
| 33 |
main_test (void) |
| 34 |
{ |
| 35 |
v = v0; |
| 36 |
init (p); |
| 37 |
qp (); |
| 38 |
check (q); |
| 39 |
v = v0; |
| 40 |
init (q); |
| 41 |
pq (); |
| 42 |
check (p); |
| 43 |
exit (0); |
| 44 |
} |