Dead
[official-gcc.git] / gomp-20050608-branch / gcc / testsuite / gcc.target / x86_64 / abi / test_passing_unions.c
blob0b6070464955af0a48b445ec45251eb86727692b
1 /* This tests passing of structs. Only integers are tested. */
3 #include "defines.h"
4 #include "args.h"
6 struct IntegerRegisters iregs;
7 struct FloatRegisters fregs;
8 unsigned int num_iregs, num_fregs;
10 struct int_struct
12 int i;
15 struct long_struct
17 long l;
20 union un1
22 char c;
23 int i;
26 union un2
28 char c1;
29 long l;
30 char c2;
33 union un3
35 struct int_struct is;
36 struct long_struct ls;
37 union un1 un;
41 void
42 check_union_passing1(union un1 u ATTRIBUTE_UNUSED)
44 check_int_arguments;
47 void
48 check_union_passing2(union un2 u ATTRIBUTE_UNUSED)
50 check_int_arguments;
53 void
54 check_union_passing3(union un3 u ATTRIBUTE_UNUSED)
56 check_int_arguments;
59 #define check_union_passing1 WRAP_CALL(check_union_passing1)
60 #define check_union_passing2 WRAP_CALL(check_union_passing2)
61 #define check_union_passing3 WRAP_CALL(check_union_passing3)
63 int
64 main (void)
66 union un1 u1;
67 #ifdef CHECK_LARGER_UNION_PASSING
68 union un2 u2;
69 union un3 u3;
70 struct int_struct is;
71 struct long_struct ls;
72 #endif /* CHECK_LARGER_UNION_PASSING */
74 /* Check a union with char, int. */
75 clear_struct_registers;
76 u1.i = 0; /* clear the struct to not have high bits left */
77 u1.c = 32;
78 iregs.I0 = 32;
79 num_iregs = 1;
80 clear_int_hardware_registers;
81 check_union_passing1(u1);
82 u1.i = 0; /* clear the struct to not have high bits left */
83 u1.i = 33;
84 iregs.I0 = 33;
85 num_iregs = 1;
86 clear_int_hardware_registers;
87 check_union_passing1(u1);
89 /* Check a union with char, long, char. */
90 #ifdef CHECK_LARGER_UNION_PASSING
91 clear_struct_registers;
92 u2.l = 0; /* clear the struct to not have high bits left */
93 u2.c1 = 34;
94 iregs.I0 = 34;
95 num_iregs = 1;
96 clear_int_hardware_registers;
97 check_union_passing2(u2);
98 u2.l = 0; /* clear the struct to not have high bits left */
99 u2.l = 35;
100 iregs.I0 = 35;
101 num_iregs = 1;
102 clear_int_hardware_registers;
103 check_union_passing2(u2);
104 u2.l = 0; /* clear the struct to not have high bits left */
105 u2.c2 = 36;
106 iregs.I0 = 36;
107 num_iregs = 1;
108 clear_int_hardware_registers;
109 check_union_passing2(u2);
111 /* check a union containing two structs and a union. */
112 clear_struct_registers;
113 is.i = 37;
114 u3.ls.l = 0; /* clear the struct to not have high bits left */
115 u3.is = is;
116 iregs.I0 = 37;
117 num_iregs = 1;
118 clear_int_hardware_registers;
119 check_union_passing3(u3);
120 ls.l = 38;
121 u3.ls.l = 0; /* clear the struct to not have high bits left */
122 u3.ls = ls;
123 iregs.I0 = 38;
124 num_iregs = 1;
125 clear_int_hardware_registers;
126 check_union_passing3(u3);
127 u1.c = 39;
128 u3.ls.l = 0; /* clear the struct to not have high bits left */
129 u3.un = u1;
130 iregs.I0 = 39;
131 num_iregs = 1;
132 clear_int_hardware_registers;
133 check_union_passing3(u3);
134 u1.i = 40;
135 u3.ls.l = 0; /* clear the struct to not have high bits left */
136 u3.un = u1;
137 iregs.I0 = 40;
138 num_iregs = 1;
139 clear_int_hardware_registers;
140 check_union_passing3(u3);
141 #endif /* CHECK_LARGER_UNION_PASSING */
143 return 0;