Skip to content

Commit 3009fbd

Browse files
committed
---
yaml --- r: 2235 b: refs/heads/master c: 05587eb h: refs/heads/master i: 2233: 3048751 2231: 100b855 v: v3
1 parent d5c47a8 commit 3009fbd

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 532a65485dc2f6a18a81c513c3abfbb34cb88e65
2+
refs/heads/master: 05587ebdff53def560e04e853fbb3c272fa586d6

trunk/src/comp/middle/trans.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6557,6 +6557,11 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
65576557
ty.ty_fn_args(ccx.tcx, fn_type),
65586558
ty.ty_fn_ret(ccx.tcx, fn_type), num_ty_param);
65596559

6560+
// FIXME: If the returned type is not nil, then we assume it's 32 bits
6561+
// wide. This is obviously wildly unsafe. We should have a better FFI
6562+
// that allows types of different sizes to be returned.
6563+
auto rty_is_nil = ty.type_is_nil(ccx.tcx, ty.ty_fn_ret(ccx.tcx, fn_type));
6564+
65606565
let vec[ValueRef] call_args = vec();
65616566
auto arg_n = 3u;
65626567
auto pass_task;
@@ -6635,7 +6640,11 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
66356640
rptr = bcx.build.BitCast(fcx.llretptr, T_ptr(T_i32()));
66366641
}
66376642

6638-
bcx.build.Store(r, rptr);
6643+
// We don't store the return value if it's nil, to avoid stomping on a nil
6644+
// pointer. This is the only concession made to non-i32 return values. See
6645+
// the FIXME above.
6646+
if (!rty_is_nil) { bcx.build.Store(r, rptr); }
6647+
66396648
bcx.build.RetVoid();
66406649

66416650
// Tie up the llallocas -> lltop edge.

0 commit comments

Comments
 (0)