Skip to content

Commit c9e601b

Browse files
committed
Drop args in native stubs too.
1 parent 5f60937 commit c9e601b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/comp/middle/trans.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6622,6 +6622,7 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
66226622
call_args += vec(lltaskptr);
66236623
for each (uint i in _uint.range(0u, num_ty_param)) {
66246624
auto llarg = llvm.LLVMGetParam(fcx.llfn, arg_n);
6625+
fcx.lltydescs += vec(llarg);
66256626
check (llarg as int != 0);
66266627
call_args += vec(vp2i(bcx, llarg));
66276628
arg_n += 1u;
@@ -6677,16 +6678,26 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
66776678
r = bcx.build.Call(llnativefn, call_args);
66786679
rptr = fcx.llretptr;
66796680
} else {
6681+
6682+
let vec[tup(ValueRef, ty.t)] drop_args = vec();
6683+
66806684
for (ty.arg arg in args) {
66816685
auto llarg = llvm.LLVMGetParam(fcx.llfn, arg_n);
66826686
check (llarg as int != 0);
66836687
push_arg(bcx, call_args, llarg, arg.ty);
6688+
if (arg.mode == ast.val) {
6689+
drop_args += vec(tup(llarg, arg.ty));
6690+
}
66846691
arg_n += 1u;
66856692
}
66866693

66876694
r = trans_native_call(bcx.build, ccx.glues, lltaskptr, ccx.externs,
66886695
ccx.tn, ccx.llmod, name, pass_task, call_args);
66896696
rptr = bcx.build.BitCast(fcx.llretptr, T_ptr(T_i32()));
6697+
6698+
for (tup(ValueRef, ty.t) d in drop_args) {
6699+
bcx = drop_ty(bcx, d._0, d._1).bcx;
6700+
}
66906701
}
66916702

66926703
// We don't store the return value if it's nil, to avoid stomping on a nil

0 commit comments

Comments
 (0)