mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Use wrapping arithmetic for exp in unchecked blocks.
This commit is contained in:
@@ -802,7 +802,12 @@ bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp)
|
||||
IRVariable left = convert(_binOp.leftExpression(), *commonType);
|
||||
IRVariable right = convert(_binOp.rightExpression(), *type(_binOp.rightExpression()).mobileType());
|
||||
|
||||
if (auto rationalNumberType = dynamic_cast<RationalNumberType const*>(_binOp.leftExpression().annotation().type))
|
||||
if (m_context.arithmetic() == Arithmetic::Wrapping)
|
||||
define(_binOp) << m_utils.wrappingIntExpFunction(
|
||||
dynamic_cast<IntegerType const&>(left.type()),
|
||||
dynamic_cast<IntegerType const&>(right.type())
|
||||
) << "(" << left.name() << ", " << right.name() << ")\n";
|
||||
else if (auto rationalNumberType = dynamic_cast<RationalNumberType const*>(_binOp.leftExpression().annotation().type))
|
||||
{
|
||||
solAssert(rationalNumberType->integerType(), "Invalid literal as the base for exponentiation.");
|
||||
solAssert(dynamic_cast<IntegerType const*>(commonType), "");
|
||||
@@ -818,7 +823,6 @@ bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp)
|
||||
dynamic_cast<IntegerType const&>(left.type()),
|
||||
dynamic_cast<IntegerType const&>(right.type())
|
||||
) << "(" << left.name() << ", " << right.name() << ")\n";
|
||||
|
||||
}
|
||||
else if (TokenTraits::isShiftOp(op))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user