Skip to content

Commit

Permalink
C-like enums are not always immediate
Browse files Browse the repository at this point in the history
  • Loading branch information
jld committed Oct 29, 2013
1 parent fcfbfde commit afab330
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/librustc/middle/trans/expr.rs
Expand Up @@ -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),
Expand Down

0 comments on commit afab330

Please sign in to comment.