File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 532a65485dc2f6a18a81c513c3abfbb34cb88e65
2
+ refs/heads/master: 05587ebdff53def560e04e853fbb3c272fa586d6
Original file line number Diff line number Diff line change @@ -6557,6 +6557,11 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
6557
6557
ty. ty_fn_args( ccx. tcx, fn_type) ,
6558
6558
ty. ty_fn_ret( ccx. tcx, fn_type) , num_ty_param) ;
6559
6559
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
+
6560
6565
let vec[ ValueRef ] call_args = vec( ) ;
6561
6566
auto arg_n = 3 u;
6562
6567
auto pass_task;
@@ -6635,7 +6640,11 @@ fn decl_native_fn_and_pair(@crate_ctxt ccx,
6635
6640
rptr = bcx. build. BitCast ( fcx. llretptr, T_ptr ( T_i32 ( ) ) ) ;
6636
6641
}
6637
6642
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
+
6639
6648
bcx. build. RetVoid ( ) ;
6640
6649
6641
6650
// Tie up the llallocas -> lltop edge.
You can’t perform that action at this time.
0 commit comments