Unified · Split
| @@ -88,7 +88,7 @@ static int ret_2float_test_callback(void *ptr) { · 87 unmodified lines | |||
| 88 | ret_2float_test_type a = {10, 35}; | 88 | ret_2float_test_type a = {10, 35}; |
| 89 | ret_2float_test_type r; | 89 | ret_2float_test_type r; |
| 90 | r = f(a); | 90 | r = f(a); |
| 91 | return ((r.x == a.x*5) && (r.y == a.y*3)) ? 0 : -1; | 91 | return ((r.x == a.x*5) && (r.y == a.y*3) && (f(a).x == a.x*5) && (f(a).y == a.y*3)) ? 0 : -1; |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | static int ret_2float_test(void) { | 94 | static int ret_2float_test(void) { |
| @@ -116,7 +116,7 @@ static int ret_2double_test_callback(void *ptr) { · 21 unmodified lines | |||
| 116 | ret_2double_test_type a = {10, 35}; | 116 | ret_2double_test_type a = {10, 35}; |
| 117 | ret_2double_test_type r; | 117 | ret_2double_test_type r; |
| 118 | r = f(a); | 118 | r = f(a); |
| 119 | return ((r.x == a.x*5) && (r.y == a.y*3)) ? 0 : -1; | 119 | return ((r.x == a.x*5) && (r.y == a.y*3) && (f(a).x == a.x*5) && (f(a).y == a.y*3)) ? 0 : -1; |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | static int ret_2double_test(void) { | 122 | static int ret_2double_test(void) { |
| @@ -130,6 +130,52 @@ static int ret_2double_test(void) { · 7 unmodified lines | |||
| 130 | return run_callback(src, ret_2double_test_callback); | 130 | return run_callback(src, ret_2double_test_callback); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | typedef struct ret_longdouble_test_type_s2 {LONG_DOUBLE x;} ret_longdouble_test_type; | ||
| 134 | typedef ret_longdouble_test_type (*ret_longdouble_test_function_type) (ret_longdouble_test_type); | ||
| 135 | |||
| 136 | static int ret_longdouble_test_callback2(void *ptr) { | ||
| 137 | ret_longdouble_test_function_type f = (ret_longdouble_test_function_type)ptr; | ||
| 138 | ret_longdouble_test_type a = {10}; | ||
| 139 | ret_longdouble_test_type r; | ||
| 140 | r = f(a); | ||
| 141 | printf("%Lf \n", a.x); | ||
| 142 | printf("%Lf \n", r.x); | ||
| 143 | return ((r.x == a.x*5) && (f(a).x == a.x*5)) ? 0 : -1; | ||
| 144 | } | ||
| 145 | |||
| 146 | static int ret_longdouble_test2(void) { | ||
| 147 | const char *src = | ||
| 148 | "typedef struct ret_longdouble_test_type_s2 {long double x;} ret_longdouble_test_type;" | ||
| 149 | "ret_longdouble_test_type f(ret_longdouble_test_type a) {\n" | ||
| 150 | " ret_longdouble_test_type r = {a.x*5};\n" | ||
| 151 | " return r;\n" | ||
| 152 | "}\n"; | ||
| 153 | |||
| 154 | return run_callback(src, ret_longdouble_test_callback2); | ||
| 155 | } | ||
| 156 | |||
| 157 | typedef struct ret_longlong_test_type_s2 {int x[4];} ret_longlong_test_type; | ||
| 158 | typedef ret_longlong_test_type (*ret_longlong_test_function_type) (ret_longlong_test_type); | ||
| 159 | |||
| 160 | static int ret_longlong_test_callback2(void *ptr) { | ||
| 161 | ret_longlong_test_function_type f = (ret_longlong_test_function_type)ptr; | ||
| 162 | ret_longlong_test_type a = {{10,11,12,13}}; | ||
| 163 | ret_longlong_test_type r; | ||
| 164 | r = f(a); | ||
| 165 | return ((r.x[2] == a.x[2]*5) && (f(a).x[2] == a.x[2]*5)) ? 0 : -1; | ||
| 166 | } | ||
| 167 | |||
| 168 | static int ret_longlong_test2(void) { | ||
| 169 | const char *src = | ||
| 170 | "typedef struct ret_longlong_test_type_s2 {int x[4];} ret_longlong_test_type;" | ||
| 171 | "ret_longlong_test_type f(ret_longlong_test_type a) {\n" | ||
| 172 | " ret_longlong_test_type r = {.x[2] = a.x[2]*5};\n" | ||
| 173 | " return r;\n" | ||
| 174 | "}\n"; | ||
| 175 | |||
| 176 | return run_callback(src, ret_longlong_test_callback2); | ||
| 177 | } | ||
| 178 | |||
| 133 | /* | 179 | /* |
| 134 | * reg_pack_test: return a small struct which should be packed into | 180 | * reg_pack_test: return a small struct which should be packed into |
| 135 | * registers (Win32) during return. | 181 | * registers (Win32) during return. |
| @@ -142,7 +188,7 @@ static int reg_pack_test_callback(void *ptr) { · 6 unmodified lines | |||
| 142 | reg_pack_test_type a = {10, 35}; | 188 | reg_pack_test_type a = {10, 35}; |
| 143 | reg_pack_test_type r; | 189 | reg_pack_test_type r; |
| 144 | r = f(a); | 190 | r = f(a); |
| 145 | return ((r.x == a.x*5) && (r.y == a.y*3)) ? 0 : -1; | 191 | return ((r.x == a.x*5) && (r.y == a.y*3) && (f(a).x == a.x*5) && (f(a).y == a.y*3)) ? 0 : -1; |
| 146 | } | 192 | } |
| 147 | 193 | ||
| 148 | static int reg_pack_test(void) { | 194 | static int reg_pack_test(void) { |
| @@ -168,7 +214,7 @@ static int reg_pack_longlong_test_callback(void *ptr) { · 19 unmodified lines | |||
| 168 | reg_pack_longlong_test_type a = {10, 35}; | 214 | reg_pack_longlong_test_type a = {10, 35}; |
| 169 | reg_pack_longlong_test_type r; | 215 | reg_pack_longlong_test_type r; |
| 170 | r = f(a); | 216 | r = f(a); |
| 171 | return ((r.x == a.x*5) && (r.y == a.y*3)) ? 0 : -1; | 217 | return ((r.x == a.x*5) && (r.y == a.y*3) && (f(a).x == a.x*5) && (f(a).y == a.y*3)) ? 0 : -1; |
| 172 | } | 218 | } |
| 173 | 219 | ||
| 174 | static int reg_pack_longlong_test(void) { | 220 | static int reg_pack_longlong_test(void) { |
| @@ -248,7 +294,7 @@ static int two_member_union_test_callback(void *ptr) { · 73 unmodified lines | |||
| 248 | two_member_union_test_type a, b; | 294 | two_member_union_test_type a, b; |
| 249 | a.x = 34; | 295 | a.x = 34; |
| 250 | b = f(a); | 296 | b = f(a); |
| 251 | return (b.x == a.x*2) ? 0 : -1; | 297 | return ((b.x == a.x*2) && (f(a).x == a.x*2)) ? 0 : -1; |
| 252 | } | 298 | } |
| 253 | 299 | ||
| 254 | static int two_member_union_test(void) { | 300 | static int two_member_union_test(void) { |
| @@ -441,6 +487,8 @@ int main(int argc, char **argv) { · 186 unmodified lines | |||
| 441 | RUN_TEST(ret_longdouble_test); | 487 | RUN_TEST(ret_longdouble_test); |
| 442 | RUN_TEST(ret_2float_test); | 488 | RUN_TEST(ret_2float_test); |
| 443 | RUN_TEST(ret_2double_test); | 489 | RUN_TEST(ret_2double_test); |
| 490 | RUN_TEST(ret_longlong_test2); | ||
| 491 | RUN_TEST(ret_longdouble_test2); | ||
| 444 | RUN_TEST(reg_pack_test); | 492 | RUN_TEST(reg_pack_test); |
| 445 | RUN_TEST(reg_pack_longlong_test); | 493 | RUN_TEST(reg_pack_longlong_test); |
| 446 | RUN_TEST(sret_test); | 494 | RUN_TEST(sret_test); |