From 89aab7e234e3c96bbae2e4066cfa1249f5d1793e Mon Sep 17 00:00:00 2001 From: Liana Husikyan Date: Thu, 4 Jun 2015 12:42:55 +0200 Subject: - style fixes - added test for uint8 = -1 which doesn't fail; todo: fix that --- Types.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'Types.cpp') diff --git a/Types.cpp b/Types.cpp index c4238f77..c10e29ea 100644 --- a/Types.cpp +++ b/Types.cpp @@ -361,22 +361,21 @@ IntegerConstantType::IntegerConstantType(Literal const& _literal) bool IntegerConstantType::isImplicitlyConvertibleTo(Type const& _convertTo) const { - if (IntegerType const* integerType = dynamic_cast(&_convertTo)) + if (auto targetType = dynamic_cast(&_convertTo)) { if (m_value == 0) return true; - int forSignBit = (integerType->isSigned() ? 1 : 0); + int forSignBit = (targetType->isSigned() ? 1 : 0); if (m_value > 0) { - if (m_value <= (u256(-1) >> (256 - integerType->getNumBits() + forSignBit))) + if (m_value <= (u256(-1) >> (256 - targetType->getNumBits() + forSignBit))) return true; } - else if (-m_value <= (u256(1) << (integerType->getNumBits() - forSignBit))) + else if (-m_value <= (u256(1) << (targetType->getNumBits() - forSignBit))) return true; return false; } - else - if (_convertTo.getCategory() == Category::FixedBytes) + else if (_convertTo.getCategory() == Category::FixedBytes) { FixedBytesType const& fixedBytes = dynamic_cast(_convertTo); return fixedBytes.getNumBytes() * 8 >= getIntegerType()->getNumBits(); -- cgit v1.2.3