mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Merge pull request #11595 from ethereum/issue-11526
Fix yul codegen bug when using binary negation.
This commit is contained in:
commit
54b1c667f1
@ -14,6 +14,7 @@ Bugfixes:
|
|||||||
* Code Generator: Fix internal compiler error when calling functions bound to calldata structs and arrays.
|
* Code Generator: Fix internal compiler error when calling functions bound to calldata structs and arrays.
|
||||||
* Code Generator: Fix internal compiler error when passing a 32-byte hex literal or a zero literal to ``bytes.concat()`` by disallowing such literals.
|
* Code Generator: Fix internal compiler error when passing a 32-byte hex literal or a zero literal to ``bytes.concat()`` by disallowing such literals.
|
||||||
* Type Checker: Fix internal error and prevent static calls to unimplemented modifiers.
|
* Type Checker: Fix internal error and prevent static calls to unimplemented modifiers.
|
||||||
|
* Yul Code Generator: Fix internal compiler error when using a long literal with bitwise negation.
|
||||||
|
|
||||||
|
|
||||||
### 0.8.6 (2021-06-22)
|
### 0.8.6 (2021-06-22)
|
||||||
|
@ -658,12 +658,21 @@ void IRGeneratorForStatements::endVisit(Return const& _return)
|
|||||||
appendCode() << "leave\n";
|
appendCode() << "leave\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void IRGeneratorForStatements::endVisit(UnaryOperation const& _unaryOperation)
|
bool IRGeneratorForStatements::visit(UnaryOperation const& _unaryOperation)
|
||||||
{
|
{
|
||||||
setLocation(_unaryOperation);
|
setLocation(_unaryOperation);
|
||||||
Type const& resultType = type(_unaryOperation);
|
Type const& resultType = type(_unaryOperation);
|
||||||
Token const op = _unaryOperation.getOperator();
|
Token const op = _unaryOperation.getOperator();
|
||||||
|
|
||||||
|
if (resultType.category() == Type::Category::RationalNumber)
|
||||||
|
{
|
||||||
|
define(_unaryOperation) << formatNumber(resultType.literalValue(nullptr)) << "\n";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
_unaryOperation.subExpression().accept(*this);
|
||||||
|
setLocation(_unaryOperation);
|
||||||
|
|
||||||
if (op == Token::Delete)
|
if (op == Token::Delete)
|
||||||
{
|
{
|
||||||
solAssert(!!m_currentLValue, "LValue not retrieved.");
|
solAssert(!!m_currentLValue, "LValue not retrieved.");
|
||||||
@ -689,8 +698,6 @@ void IRGeneratorForStatements::endVisit(UnaryOperation const& _unaryOperation)
|
|||||||
m_currentLValue->kind
|
m_currentLValue->kind
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else if (resultType.category() == Type::Category::RationalNumber)
|
|
||||||
define(_unaryOperation) << formatNumber(resultType.literalValue(nullptr)) << "\n";
|
|
||||||
else if (resultType.category() == Type::Category::Integer)
|
else if (resultType.category() == Type::Category::Integer)
|
||||||
{
|
{
|
||||||
solAssert(resultType == type(_unaryOperation.subExpression()), "Result type doesn't match!");
|
solAssert(resultType == type(_unaryOperation.subExpression()), "Result type doesn't match!");
|
||||||
@ -749,6 +756,8 @@ void IRGeneratorForStatements::endVisit(UnaryOperation const& _unaryOperation)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
solUnimplementedAssert(false, "Unary operator not yet implemented");
|
solUnimplementedAssert(false, "Unary operator not yet implemented");
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp)
|
bool IRGeneratorForStatements::visit(BinaryOperation const& _binOp)
|
||||||
|
@ -105,7 +105,7 @@ public:
|
|||||||
bool visit(Continue const& _continueStatement) override;
|
bool visit(Continue const& _continueStatement) override;
|
||||||
bool visit(Break const& _breakStatement) override;
|
bool visit(Break const& _breakStatement) override;
|
||||||
void endVisit(Return const& _return) override;
|
void endVisit(Return const& _return) override;
|
||||||
void endVisit(UnaryOperation const& _unaryOperation) override;
|
bool visit(UnaryOperation const& _unaryOperation) override;
|
||||||
bool visit(BinaryOperation const& _binOp) override;
|
bool visit(BinaryOperation const& _binOp) override;
|
||||||
void endVisit(FunctionCall const& _funCall) override;
|
void endVisit(FunctionCall const& _funCall) override;
|
||||||
void endVisit(FunctionCallOptions const& _funCallOptions) override;
|
void endVisit(FunctionCallOptions const& _funCallOptions) override;
|
||||||
|
@ -236,8 +236,6 @@ object "C_81" {
|
|||||||
let expr_25 := checked_exp_t_rational_2_by_1_t_uint256(expr_24)
|
let expr_25 := checked_exp_t_rational_2_by_1_t_uint256(expr_24)
|
||||||
/// @src 0:187,200
|
/// @src 0:187,200
|
||||||
let var_w_22 := expr_25
|
let var_w_22 := expr_25
|
||||||
/// @src 0:214,215
|
|
||||||
let expr_29 := 0x02
|
|
||||||
/// @src 0:213,215
|
/// @src 0:213,215
|
||||||
let expr_30 := 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe
|
let expr_30 := 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe
|
||||||
/// @src 0:212,216
|
/// @src 0:212,216
|
||||||
@ -285,8 +283,6 @@ object "C_81" {
|
|||||||
/// @src 0:303,313
|
/// @src 0:303,313
|
||||||
var_w_22 := expr_56
|
var_w_22 := expr_56
|
||||||
let expr_57 := expr_56
|
let expr_57 := expr_56
|
||||||
/// @src 0:323,324
|
|
||||||
let expr_60 := 0x01
|
|
||||||
/// @src 0:322,324
|
/// @src 0:322,324
|
||||||
let expr_61 := 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
let expr_61 := 0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff
|
||||||
/// @src 0:321,325
|
/// @src 0:321,325
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
contract C {
|
||||||
|
function f() public returns (bool) {
|
||||||
|
return
|
||||||
|
0 <
|
||||||
|
~~84926290883049832306107864558384249403874903260938453235235091622489261765859;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// ====
|
||||||
|
// compileViaYul: also
|
||||||
|
// ----
|
||||||
|
// f() -> true
|
Loading…
Reference in New Issue
Block a user