mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Fix control flow check for unary operators
This commit is contained in:
parent
6c4325ca03
commit
43a612e420
@ -63,6 +63,7 @@ bool ControlFlowBuilder::visit(BinaryOperation const& _operation)
|
|||||||
case Token::Or:
|
case Token::Or:
|
||||||
case Token::And:
|
case Token::And:
|
||||||
{
|
{
|
||||||
|
visitNode(_operation);
|
||||||
solAssert(!_operation.annotation().userDefinedFunction);
|
solAssert(!_operation.annotation().userDefinedFunction);
|
||||||
visitNode(_operation);
|
visitNode(_operation);
|
||||||
appendControlFlow(_operation.leftExpression());
|
appendControlFlow(_operation.leftExpression());
|
||||||
@ -75,9 +76,10 @@ bool ControlFlowBuilder::visit(BinaryOperation const& _operation)
|
|||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
bool result = ASTConstVisitor::visit(_operation);
|
visitNode(_operation);
|
||||||
if (_operation.annotation().userDefinedFunction)
|
if (_operation.annotation().userDefinedFunction)
|
||||||
{
|
{
|
||||||
|
visitNode(_operation);
|
||||||
solAssert(!m_currentNode->resolveFunctionCall(nullptr));
|
solAssert(!m_currentNode->resolveFunctionCall(nullptr));
|
||||||
m_currentNode->functionCall = _operation.annotation().userDefinedFunction;
|
m_currentNode->functionCall = _operation.annotation().userDefinedFunction;
|
||||||
|
|
||||||
@ -86,7 +88,7 @@ bool ControlFlowBuilder::visit(BinaryOperation const& _operation)
|
|||||||
connect(m_currentNode, nextNode);
|
connect(m_currentNode, nextNode);
|
||||||
m_currentNode = nextNode;
|
m_currentNode = nextNode;
|
||||||
}
|
}
|
||||||
return result;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,9 +97,9 @@ bool ControlFlowBuilder::visit(UnaryOperation const& _operation)
|
|||||||
{
|
{
|
||||||
solAssert(!!m_currentNode, "");
|
solAssert(!!m_currentNode, "");
|
||||||
|
|
||||||
ASTConstVisitor::visit(_operation);
|
|
||||||
if (_operation.annotation().userDefinedFunction)
|
if (_operation.annotation().userDefinedFunction)
|
||||||
{
|
{
|
||||||
|
visitNode(_operation);
|
||||||
solAssert(!m_currentNode->resolveFunctionCall(nullptr));
|
solAssert(!m_currentNode->resolveFunctionCall(nullptr));
|
||||||
m_currentNode->functionCall = _operation.annotation().userDefinedFunction;
|
m_currentNode->functionCall = _operation.annotation().userDefinedFunction;
|
||||||
|
|
||||||
@ -105,7 +107,9 @@ bool ControlFlowBuilder::visit(UnaryOperation const& _operation)
|
|||||||
|
|
||||||
connect(m_currentNode, nextNode);
|
connect(m_currentNode, nextNode);
|
||||||
m_currentNode = nextNode;
|
m_currentNode = nextNode;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
struct S { bool f; }
|
||||||
|
|
||||||
|
using {add as +} for S;
|
||||||
|
|
||||||
|
function add(S storage x, S storage) pure returns (S storage) { return x; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
S s;
|
||||||
|
function f() public {
|
||||||
|
S storage x = s;
|
||||||
|
S storage y;
|
||||||
|
x + y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----
|
||||||
|
// TypeError 3464: (230-231): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
|
@ -0,0 +1,15 @@
|
|||||||
|
struct S { int f; }
|
||||||
|
|
||||||
|
using {sub as -} for S;
|
||||||
|
|
||||||
|
function sub(S storage x) pure returns (S storage) { return x; }
|
||||||
|
|
||||||
|
contract C {
|
||||||
|
function f() public {
|
||||||
|
S storage y;
|
||||||
|
-y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----
|
||||||
|
// TypeError 3464: (181-182): This variable is of storage pointer type and can be accessed without prior assignment, which would lead to undefined behaviour.
|
Loading…
Reference in New Issue
Block a user