trans: Use inttoptr as appropriate when casting return values of C stack functions

This commit is contained in:
Patrick Walton 2011-09-30 12:07:50 -07:00
parent 472dd71fea
commit dcf0e807fb

View File

@ -4029,7 +4029,15 @@ fn trans_c_stack_native_call(bcx: @block_ctxt, f: @ast::expr,
let ret_ty = ty::ty_fn_ret(bcx_tcx(bcx), fn_ty);
check type_has_static_size(ccx, ret_ty);
let llretty = type_of(ccx, f.span, ret_ty);
let llretval = TruncOrBitCast(bcx, llrawretval, llretty);
log_err "casting " + val_str(ccx.tn, llrawretval) + " to " +
lib::llvm::type_to_str(ccx.tn, llretty);
let llretval;
if lib::llvm::llvm::LLVMGetTypeKind(llretty) as int == 11 { // pointer
llretval = IntToPtr(bcx, llrawretval, llretty);
} else {
llretval = TruncOrBitCast(bcx, llrawretval, llretty);
}
// Forget about anything we moved out.
bcx = zero_and_revoke(bcx, to_zero, to_revoke);