mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 06:22:00 +00:00
trans: Use inttoptr as appropriate when casting return values of C stack functions
This commit is contained in:
parent
472dd71fea
commit
dcf0e807fb
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user