C-like enums are not always immediate

This commit is contained in:
Jed Davis 2013-10-03 13:59:34 -07:00
parent fcfbfde0b7
commit afab3307a0

View File

@ -1726,9 +1726,14 @@ fn trans_imm_cast(bcx: @mut Block, expr: &ast::Expr,
(cast_enum, cast_float) => {
let bcx = bcx;
let repr = adt::represent_type(ccx, t_in);
let slot = Alloca(bcx, ll_t_in, "");
Store(bcx, llexpr, slot);
let lldiscrim_a = adt::trans_get_discr(bcx, repr, slot, Some(Type::i64()));
let llexpr_ptr;
if type_is_immediate(ccx, t_in) {
llexpr_ptr = Alloca(bcx, ll_t_in, "");
Store(bcx, llexpr, llexpr_ptr);
} else {
llexpr_ptr = llexpr;
}
let lldiscrim_a = adt::trans_get_discr(bcx, repr, llexpr_ptr, Some(Type::i64()));
match k_out {
cast_integral => int_cast(bcx, ll_t_out,
val_ty(lldiscrim_a),