OSDN Git Service

Backported from mainline
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.c-torture / compile / sra-1.c
1 /* { dg-do compile } */
2 /* { dg-options "-O1" } */
3 /* Let gimple verifier check what SRA does to unions and single-field
4    strucutres . */
5
6 struct sim_struct
7 {
8   int x;
9 };
10
11 extern struct sim_struct get_x(void);
12
13 struct sim_struct foo (void)
14 {
15   struct sim_struct simple;
16
17   simple = get_x ();
18   if (simple.x % 2)
19     simple.x = 39;
20   else
21     simple.x -=8;
22
23   return simple;
24 }
25
26 struct sim_cmplx
27 {
28   _Complex double c;
29 };
30
31 extern struct sim_cmplx get_sc (void);
32
33 _Complex double foo_c (void)
34 {
35   struct sim_cmplx simple;
36
37   simple = get_sc ();
38   if (__real__ simple.c > 200.3)
39     __imag__ simple.c -= 2.4;
40
41   return simple.c;
42 }
43
44
45 union sim_union
46 {
47   int i;
48   float d;
49 };
50
51 extern union sim_union get_y (void);
52
53 union sim_union bar (void)
54 {
55   union sim_union simple;
56
57   simple = get_y ();
58   if (simple.d > 8.2)
59     simple.i = 300;
60
61   return simple;
62 }
63
64 extern int get_int (void);
65
66 int bar_i (void)
67 {
68   union sim_union simple;
69
70   simple = get_y ();
71   if (simple.d > 8.2)
72     simple.i = get_int ();
73
74   return simple.i;
75 }