Disallow implicit conversion from rational (literal) to address

This commit is contained in:
Jason Cobb 2018-02-15 23:23:27 -05:00 committed by Alex Beregszaszi
parent b7003505c4
commit 3d88eca531

View File

@ -858,11 +858,13 @@ bool RationalNumberType::isImplicitlyConvertibleTo(Type const& _convertTo) const
{ {
if (_convertTo.category() == Category::Integer) if (_convertTo.category() == Category::Integer)
{ {
if (m_value == rational(0))
return true;
if (isFractional()) if (isFractional())
return false; return false;
IntegerType const& targetType = dynamic_cast<IntegerType const&>(_convertTo); IntegerType const& targetType = dynamic_cast<IntegerType const&>(_convertTo);
if (targetType.isAddress())
return false;
if (m_value == rational(0))
return true;
unsigned forSignBit = (targetType.isSigned() ? 1 : 0); unsigned forSignBit = (targetType.isSigned() ? 1 : 0);
if (m_value > rational(0)) if (m_value > rational(0))
{ {