diff options
| author | Patrick Walton <[email protected]> | 2011-04-26 18:48:34 -0700 |
|---|---|---|
| committer | Patrick Walton <[email protected]> | 2011-04-26 19:01:30 -0700 |
| commit | 05587ebdff53def560e04e853fbb3c272fa586d6 (patch) | |
| tree | e7137bf6ac7405636b93d0775b25c5f5aaaba638 | |
| parent | rustc: Actually write the optimized bitcode when --save-temps is on (diff) | |
| download | rust-05587ebdff53def560e04e853fbb3c272fa586d6.tar.xz rust-05587ebdff53def560e04e853fbb3c272fa586d6.zip | |
rustc: Ignore the return value of native functions that return nil. stage1 can build libstd now, though it leaks.
| -rw-r--r-- | src/comp/middle/trans.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs index a36821a7..f789a216 100644 --- a/src/comp/middle/trans.rs +++ b/src/comp/middle/trans.rs @@ -6557,6 +6557,11 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx, ty.ty_fn_args(ccx.tcx, fn_type), ty.ty_fn_ret(ccx.tcx, fn_type), num_ty_param); + // FIXME: If the returned type is not nil, then we assume it's 32 bits + // wide. This is obviously wildly unsafe. We should have a better FFI + // that allows types of different sizes to be returned. + auto rty_is_nil = ty.type_is_nil(ccx.tcx, ty.ty_fn_ret(ccx.tcx, fn_type)); + let vec[ValueRef] call_args = vec(); auto arg_n = 3u; auto pass_task; @@ -6635,7 +6640,11 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx, rptr = bcx.build.BitCast(fcx.llretptr, T_ptr(T_i32())); } - bcx.build.Store(r, rptr); + // We don't store the return value if it's nil, to avoid stomping on a nil + // pointer. This is the only concession made to non-i32 return values. See + // the FIXME above. + if (!rty_is_nil) { bcx.build.Store(r, rptr); } + bcx.build.RetVoid(); // Tie up the llallocas -> lltop edge. |