Adapt interpreter.
This commit is contained in:
parent
1480b1c524
commit
7567f1f31d
@ -569,16 +569,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||||||
// checked operation, just a comparison with the minimum
|
// checked operation, just a comparison with the minimum
|
||||||
// value, so we have to check for the assert message.
|
// value, so we have to check for the assert message.
|
||||||
if !bx.cx().check_overflow() {
|
if !bx.cx().check_overflow() {
|
||||||
if let AssertKind::OverflowNeg(_)
|
let unchecked_overflow = match msg {
|
||||||
| AssertKind::Overflow(
|
AssertKind::OverflowNeg(..) => true,
|
||||||
mir::BinOp::Add
|
AssertKind::Overflow(op, ..) => op.is_checkable(),
|
||||||
| mir::BinOp::Sub
|
_ => false,
|
||||||
| mir::BinOp::Mul
|
};
|
||||||
| mir::BinOp::Shl
|
if unchecked_overflow {
|
||||||
| mir::BinOp::Shr,
|
|
||||||
..,
|
|
||||||
) = *msg
|
|
||||||
{
|
|
||||||
const_cond = Some(expected);
|
const_cond = Some(expected);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,8 +137,14 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Assert { ref cond, expected, ref msg, target, cleanup } => {
|
Assert { ref cond, expected, ref msg, target, cleanup } => {
|
||||||
|
let ignored = !self.tcx.sess.overflow_checks()
|
||||||
|
&& match msg {
|
||||||
|
mir::AssertKind::OverflowNeg(..) => true,
|
||||||
|
mir::AssertKind::Overflow(op, ..) => op.is_checkable(),
|
||||||
|
_ => false,
|
||||||
|
};
|
||||||
let cond_val = self.read_scalar(&self.eval_operand(cond, None)?)?.to_bool()?;
|
let cond_val = self.read_scalar(&self.eval_operand(cond, None)?)?.to_bool()?;
|
||||||
if expected == cond_val {
|
if ignored || expected == cond_val {
|
||||||
self.go_to_block(target);
|
self.go_to_block(target);
|
||||||
} else {
|
} else {
|
||||||
M::assert_panic(self, msg, cleanup)?;
|
M::assert_panic(self, msg, cleanup)?;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user