Debian Codegraph @

gcc/testsuite/gcc.c-torture/compile/sra-1.c

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