OSDN Git Service

libcpp/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / union-5.c
1 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
2 /* { dg-options "-O -fgcse -fno-split-wide-types" } */
3
4 extern void abort(void);
5
6 typedef unsigned short int uint16_t;
7 typedef unsigned int uint32_t;
8 typedef unsigned long long uint64_t;
9
10 typedef struct
11 {
12   uint16_t thread;
13   uint16_t phase;
14 } s32;
15
16 typedef union
17 {
18   uint32_t i;
19   s32 s;
20 } u32;
21
22 typedef union
23 {
24   uint64_t i;
25   u32 u;
26 } u64;
27
28 static __attribute__((noinline))
29 void foo(int val)
30 {
31   u64 data;
32   uint32_t thread;
33
34   data.u.i = 0x10000L;
35   thread = data.u.s.thread;
36   if (val)
37     abort ();
38   if (thread)
39     abort ();
40 }
41
42 int main(void)
43 {
44   foo (0);
45   return 0;
46 }