Bool variables should not allow arithmetic comparison

This commit is contained in:
Leonardo Alt
2018-05-16 18:32:47 +02:00
committed by chriseth
parent 9705678269
commit 0b6eea0c55
3 changed files with 2 additions and 35 deletions
+1 -1
View File
@@ -1358,7 +1358,7 @@ TypePointer BoolType::binaryOperatorResult(Token::Value _operator, TypePointer c
{
if (category() != _other->category())
return TypePointer();
if (Token::isCompareOp(_operator) || _operator == Token::And || _operator == Token::Or)
if (_operator == Token::Equal || _operator == Token::NotEqual || _operator == Token::And || _operator == Token::Or)
return _other;
else
return TypePointer();
+1 -5
View File
@@ -485,11 +485,7 @@ void SMTChecker::compareOperation(BinaryOperation const& _op)
solUnimplementedAssert(SSAVariable::isBool(_op.annotation().commonType->category()), "Operation not yet supported");
value = make_shared<smt::Expression>(
op == Token::Equal ? (left == right) :
op == Token::NotEqual ? (left != right) :
op == Token::LessThan ? (!left && right) :
op == Token::LessThanOrEqual ? (!left || right) :
op == Token::GreaterThan ? (left && !right) :
/*op == Token::GreaterThanOrEqual*/ (left || !right)
/*op == Token::NotEqual*/ (left != right)
);
}
// TODO: check that other values for op are not possible.