Unified · Split
| @@ -88,7 +88,7 @@ static int ret_2float_test_callback(void *ptr) { · 87 unmodified lines | ||
| 88 | 88 | ret_2float_test_type a = {10, 35}; |
| 89 | 89 | ret_2float_test_type r; |
| 90 | 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 | 94 | static int ret_2float_test(void) { |
| @@ -116,7 +116,7 @@ static int ret_2double_test_callback(void *ptr) { · 21 unmodified lines | ||
| 116 | 116 | ret_2double_test_type a = {10, 35}; |
| 117 | 117 | ret_2double_test_type r; |
| 118 | 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 | 122 | static int ret_2double_test(void) { |
| @@ -130,6 +130,52 @@ static int ret_2double_test(void) { · 7 unmodified lines | ||
| 130 | 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 | 180 | * reg_pack_test: return a small struct which should be packed into |
| 135 | 181 | * registers (Win32) during return. |
| @@ -142,7 +188,7 @@ static int reg_pack_test_callback(void *ptr) { · 6 unmodified lines | ||
| 142 | 188 | reg_pack_test_type a = {10, 35}; |
| 143 | 189 | reg_pack_test_type r; |
| 144 | 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 | 194 | static int reg_pack_test(void) { |
| @@ -168,7 +214,7 @@ static int reg_pack_longlong_test_callback(void *ptr) { · 19 unmodified lines | ||
| 168 | 214 | reg_pack_longlong_test_type a = {10, 35}; |
| 169 | 215 | reg_pack_longlong_test_type r; |
| 170 | 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 | 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 | 294 | two_member_union_test_type a, b; |
| 249 | 295 | a.x = 34; |
| 250 | 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 | 300 | static int two_member_union_test(void) { |
| @@ -441,6 +487,8 @@ int main(int argc, char **argv) { · 186 unmodified lines | ||
| 441 | 487 | RUN_TEST(ret_longdouble_test); |
| 442 | 488 | RUN_TEST(ret_2float_test); |
| 443 | 489 | RUN_TEST(ret_2double_test); |
| 490 | + RUN_TEST(ret_longlong_test2); | |
| 491 | + RUN_TEST(ret_longdouble_test2); | |
| 444 | 492 | RUN_TEST(reg_pack_test); |
| 445 | 493 | RUN_TEST(reg_pack_longlong_test); |
| 446 | 494 | RUN_TEST(sret_test); |