Handle _|_ values properly in trans

Generate an LLVMUndef value of the proper type for an argument of
type _|_. Otherwise we get an LLVM assertion failure.
This commit is contained in:
Tim Chevalier 2011-06-02 17:50:37 -07:00
parent 468786e36d
commit ba377c043d

View file

@ -5121,8 +5121,6 @@ fn trans_bind(&@block_ctxt cx, &@ast::expr f,
ret res(bcx, pair_v);
}
}
fail; // sadly needed b/c the compiler doesn't know yet that unimpl fails
}
fn trans_arg_expr(&@block_ctxt cx,
@ -5168,8 +5166,15 @@ fn trans_arg_expr(&@block_ctxt cx,
if (arg.mode != ty::mo_alias) {
bcx = take_ty(bcx, val, e_ty).bcx;
}
if (ty::type_contains_params(cx.fcx.lcx.ccx.tcx, arg.ty)) {
if (ty::type_is_bot(cx.fcx.lcx.ccx.tcx, e_ty)) {
// For values of type _|_, we generate an
// "undef" value, as such a value should never
// be inspected. It's important for the value
// to have type lldestty0 (the callee's expected type).
val = llvm::LLVMGetUndef(lldestty0);
}
else if (ty::type_contains_params(cx.fcx.lcx.ccx.tcx, arg.ty)) {
auto lldestty = lldestty0;
if (arg.mode == ty::mo_val) {
// FIXME: we'd prefer to use &&, but rustboot doesn't like it