From ab251c7e7d18a03184ab11e2d1c99d05af7d97f9 Mon Sep 17 00:00:00 2001 From: Leonardo Alt Date: Fri, 27 Apr 2018 11:35:58 +0200 Subject: Bool variables should not allow arithmetic comparison --- libsolidity/ast/Types.cpp | 2 +- libsolidity/formal/SMTChecker.cpp | 6 +----- 2 files changed, 2 insertions(+), 6 deletions(-) (limited to 'libsolidity') diff --git a/libsolidity/ast/Types.cpp b/libsolidity/ast/Types.cpp index 425e5045..a8d9a1d3 100644 --- a/libsolidity/ast/Types.cpp +++ b/libsolidity/ast/Types.cpp @@ -1374,7 +1374,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(); diff --git a/libsolidity/formal/SMTChecker.cpp b/libsolidity/formal/SMTChecker.cpp index c4dee22d..7facdf92 100644 --- a/libsolidity/formal/SMTChecker.cpp +++ b/libsolidity/formal/SMTChecker.cpp @@ -472,11 +472,7 @@ void SMTChecker::compareOperation(BinaryOperation const& _op) solUnimplementedAssert(SSAVariable::isBool(_op.annotation().commonType->category()), "Operation not yet supported"); value = make_shared( 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. -- cgit