rustc: Do pointer casts when casting native types

This commit is contained in:
Patrick Walton 2011-03-18 18:12:58 -07:00
parent 9c0c0af1b2
commit 8c48fae726
1 changed files with 3 additions and 1 deletions

View File

@ -3596,7 +3596,9 @@ fn trans_cast(@block_ctxt cx, @ast.expr e, &ast.ann ann) -> result {
auto t = node_ann_type(cx.fcx.ccx, ann);
auto lldsttype = type_of(cx.fcx.ccx, t);
if (!ty.type_is_fp(t)) {
if (llvm.LLVMGetIntTypeWidth(lldsttype) >
if (ty.type_is_native(ty.expr_ty(e))) {
e_res.val = e_res.bcx.build.PtrToInt(e_res.val, lldsttype);
} else if (llvm.LLVMGetIntTypeWidth(lldsttype) >
llvm.LLVMGetIntTypeWidth(llsrctype)) {
if (ty.type_is_signed(t)) {
// Widening signed cast.