mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
ControlFlowAnalyser: Also consider called functions in a flow
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
==== Source: s1.sol ====
|
||||
function normal() pure returns (uint) { return 1337; }
|
||||
function reverting() pure returns (uint) { revert(); }
|
||||
==== Source: s2.sol ====
|
||||
import "s1.sol";
|
||||
contract C
|
||||
{
|
||||
function foo() public pure returns (uint) { normal(); }
|
||||
function bar() public pure returns (uint) { reverting(); }
|
||||
}
|
||||
// ----
|
||||
// Warning 6321: (s2.sol:67-71): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
@@ -0,0 +1,16 @@
|
||||
==== Source: s1.sol ====
|
||||
library L
|
||||
{
|
||||
function normal() public pure returns (uint) { return 1337; }
|
||||
function reverting() public pure returns (uint) { revert(); }
|
||||
}
|
||||
==== Source: s2.sol ====
|
||||
import "s1.sol";
|
||||
contract C
|
||||
{
|
||||
function foo() public pure returns (uint) { L.normal(); }
|
||||
function bar() public pure returns (uint) { L.reverting(); }
|
||||
}
|
||||
// ----
|
||||
// Warning 6321: (s2.sol:67-71): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (s2.sol:126-130): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
==== Source: s1.sol ====
|
||||
contract C
|
||||
{
|
||||
function normal() public pure returns (uint) { return 1337; }
|
||||
function reverting() public pure returns (uint) { revert(); }
|
||||
}
|
||||
==== Source: s2.sol ====
|
||||
import "s1.sol";
|
||||
contract D is C
|
||||
{
|
||||
function foo() public pure returns (uint) { normal(); }
|
||||
function bar() public pure returns (uint) { reverting(); }
|
||||
}
|
||||
// ----
|
||||
// Warning 6321: (s2.sol:72-76): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
==== Source: s1.sol ====
|
||||
contract C
|
||||
{
|
||||
function normal(bool x) public pure returns (uint)
|
||||
{
|
||||
if (x)
|
||||
return xxx();
|
||||
else
|
||||
return yyy();
|
||||
}
|
||||
function yyy() public pure returns (uint) { revert(); }
|
||||
function bar() public pure returns (uint) { normal(true); }
|
||||
|
||||
function xxx() public virtual pure returns (uint) { return 1; }
|
||||
}
|
||||
==== Source: s2.sol ====
|
||||
import "s1.sol";
|
||||
contract D is C
|
||||
{
|
||||
function foo() public pure returns (uint) { normal(false); }
|
||||
function xxx() public override pure returns(uint) { revert(); }
|
||||
}
|
||||
// ----
|
||||
// Warning 6321: (s1.sol:215-219): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
Reference in New Issue
Block a user