mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Take revert statement into account in control flow graph.
This commit is contained in:
parent
d5669696d5
commit
1057fd5355
@ -236,6 +236,16 @@ bool ControlFlowBuilder::visit(Throw const& _throw)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ControlFlowBuilder::visit(RevertStatement const& _revert)
|
||||
{
|
||||
solAssert(!!m_currentNode, "");
|
||||
solAssert(!!m_revertNode, "");
|
||||
visitNode(_revert);
|
||||
connect(m_currentNode, m_revertNode);
|
||||
m_currentNode = newLabel();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ControlFlowBuilder::visit(PlaceholderStatement const&)
|
||||
{
|
||||
solAssert(!!m_currentNode, "");
|
||||
|
@ -56,6 +56,7 @@ private:
|
||||
bool visit(Break const&) override;
|
||||
bool visit(Continue const&) override;
|
||||
bool visit(Throw const&) override;
|
||||
bool visit(RevertStatement const&) override;
|
||||
bool visit(PlaceholderStatement const&) override;
|
||||
bool visit(FunctionCall const& _functionCall) override;
|
||||
bool visit(ModifierInvocation const& _modifierInvocation) override;
|
||||
|
21
test/libsolidity/syntaxTests/errors/duplicate.sol
Normal file
21
test/libsolidity/syntaxTests/errors/duplicate.sol
Normal file
@ -0,0 +1,21 @@
|
||||
==== Source: A ====
|
||||
|
||||
error E();
|
||||
|
||||
==== Source: B ====
|
||||
|
||||
error E();
|
||||
|
||||
==== Source: C ====
|
||||
|
||||
import "A" as A;
|
||||
import "B" as B;
|
||||
|
||||
contract Test {
|
||||
function f() public pure {
|
||||
revert A.E();
|
||||
}
|
||||
function g() public pure {
|
||||
revert B.E();
|
||||
}
|
||||
}
|
10
test/libsolidity/syntaxTests/errors/unreachable.sol
Normal file
10
test/libsolidity/syntaxTests/errors/unreachable.sol
Normal file
@ -0,0 +1,10 @@
|
||||
contract C {
|
||||
error E();
|
||||
uint x = 2;
|
||||
function f() public {
|
||||
revert E();
|
||||
x = 4;
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 5740: (98-103): Unreachable code.
|
Loading…
Reference in New Issue
Block a user