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:
@@ -9,5 +9,3 @@ contract C {
|
||||
// ====
|
||||
// SMTEngine: all
|
||||
// ----
|
||||
// Warning 6321: (48-52): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (54-58): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
|
||||
@@ -23,18 +23,5 @@ a;
|
||||
// ====
|
||||
// SMTEngine: all
|
||||
// ----
|
||||
// Warning 6321: (130-134): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (138-142): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (146-150): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (154-158): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (162-166): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (170-174): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (178-182): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (186-190): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (194-198): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (202-206): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (208-211): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (213-217): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (219-226): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6133: (39-57): Statement has no effect.
|
||||
// Warning 6133: (63-74): Statement has no effect.
|
||||
|
||||
@@ -17,3 +17,5 @@ contract C
|
||||
// ====
|
||||
// SMTEngine: all
|
||||
// ----
|
||||
// Warning 5740: (137-157): Unreachable code.
|
||||
// Warning 5740: (199-237): Unreachable code.
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
contract C
|
||||
{
|
||||
function iWillRevert() pure public { revert(); }
|
||||
|
||||
function test(bool _param) pure external returns(uint256)
|
||||
{
|
||||
if (_param) return 1;
|
||||
|
||||
iWillRevert();
|
||||
}
|
||||
}
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
function iWillRevert() pure { revert(); }
|
||||
|
||||
contract C {
|
||||
function test(bool _param) pure external returns(uint256) {
|
||||
if (_param)
|
||||
return 1;
|
||||
|
||||
iWillRevert();
|
||||
}
|
||||
}
|
||||
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
library L
|
||||
{
|
||||
function iWillRevert() public pure { revert(); }
|
||||
}
|
||||
|
||||
contract C
|
||||
{
|
||||
function test(bool _param) pure external returns(uint256)
|
||||
{
|
||||
if (_param) return 1;
|
||||
|
||||
L.iWillRevert();
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// Warning 6321: (128-135): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
contract C
|
||||
{
|
||||
function iWillRevertLevel1() pure public { revert(); }
|
||||
function iWillRevert() pure public { iWillRevertLevel1(); }
|
||||
|
||||
function test(bool _param) pure external returns(uint256)
|
||||
{
|
||||
if (_param) return 1;
|
||||
|
||||
iWillRevert();
|
||||
}
|
||||
}
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
contract C
|
||||
{
|
||||
function iWillRevertLevel2() pure public { revert(); }
|
||||
function iWillRevertLevel1() pure public { iWillRevertLevel2(); }
|
||||
function iWillRevert() pure public { iWillRevertLevel1(); }
|
||||
|
||||
function test(bool _param) pure external returns(uint256)
|
||||
{
|
||||
if (_param) return 1;
|
||||
|
||||
iWillRevert();
|
||||
}
|
||||
}
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
contract C
|
||||
{
|
||||
function iWillRevertLevel2(bool _recurse) pure public
|
||||
{
|
||||
if (_recurse)
|
||||
iWillRevertLevel1();
|
||||
else
|
||||
revert();
|
||||
}
|
||||
|
||||
function iWillRevertLevel1() pure public { iWillRevertLevel2(true); }
|
||||
function iWillRevert() pure public { iWillRevertLevel1(); }
|
||||
|
||||
function test(bool _param) pure external returns(uint256)
|
||||
{
|
||||
if (_param) return 1;
|
||||
|
||||
iWillRevert();
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
abstract contract B
|
||||
{
|
||||
function iWillRevert() pure public virtual { revert(); }
|
||||
}
|
||||
|
||||
abstract contract X
|
||||
{
|
||||
function iWillRevert() pure public virtual { revert(); }
|
||||
}
|
||||
|
||||
contract C is B, X
|
||||
{
|
||||
function iWillRevert() pure public override(B, X) { }
|
||||
|
||||
function test(bool _param) pure external returns(uint256)
|
||||
{
|
||||
if (_param) return 1;
|
||||
|
||||
B.iWillRevert();
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
@@ -0,0 +1,18 @@
|
||||
abstract contract B
|
||||
{
|
||||
function iWillRevert() pure public virtual { revert(); }
|
||||
}
|
||||
|
||||
contract C is B
|
||||
{
|
||||
function iWillRevert() pure public override { }
|
||||
|
||||
function test(bool _param) pure external returns(uint256)
|
||||
{
|
||||
if (_param) return 1;
|
||||
|
||||
super.iWillRevert();
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
abstract contract B
|
||||
{
|
||||
function iWillRevert() pure public virtual { revert(); }
|
||||
|
||||
function test2(bool _param) pure external returns(uint256)
|
||||
{
|
||||
if (_param) return 1;
|
||||
|
||||
iWillRevert();
|
||||
}
|
||||
}
|
||||
|
||||
contract C is B
|
||||
{
|
||||
function iWillRevert() pure public override { }
|
||||
|
||||
function test(bool _param) pure external returns(uint256)
|
||||
{
|
||||
if (_param) return 1;
|
||||
|
||||
iWillRevert();
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
// Warning 6321: (146-153): Unnamed return variable can remain unassigned when the function is called when "C" is the most derived contract. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (381-388): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
abstract contract B
|
||||
{
|
||||
function iWillRevert() pure public virtual { }
|
||||
}
|
||||
|
||||
contract C is B
|
||||
{
|
||||
function iWillRevert() pure public override { revert(); }
|
||||
|
||||
function test(bool _param) pure external returns(uint256)
|
||||
{
|
||||
if (_param) return 1;
|
||||
|
||||
iWillRevert();
|
||||
}
|
||||
}
|
||||
|
||||
// ----
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
abstract contract B
|
||||
{
|
||||
function iWillRevert() pure public virtual { }
|
||||
|
||||
function test(bool _param) pure external returns(uint256)
|
||||
{
|
||||
if (_param) return 1;
|
||||
|
||||
iWillRevert();
|
||||
}
|
||||
}
|
||||
|
||||
contract C is B
|
||||
{
|
||||
function iWillRevert() pure public override { revert(); }
|
||||
}
|
||||
|
||||
// ----
|
||||
// Warning 6321: (135-142): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
contract A {
|
||||
function f() public virtual returns (uint) { g(); }
|
||||
function g() internal virtual { revert(); }
|
||||
}
|
||||
contract B is A {
|
||||
function f() public override returns (uint) { A.f(); }
|
||||
function g() internal override {}
|
||||
}
|
||||
// ----
|
||||
// Warning 6321: (52-56): Unnamed return variable can remain unassigned when the function is called when "B" is the most derived contract. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (173-177): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
contract A {
|
||||
function f() public virtual returns (uint) { g(); }
|
||||
function g() internal virtual { revert(); }
|
||||
}
|
||||
contract B is A {
|
||||
function f() public virtual override returns (uint) { A.f(); }
|
||||
function g() internal virtual override { A.g(); }
|
||||
}
|
||||
contract C is B {
|
||||
function f() public virtual override returns (uint) { A.f(); }
|
||||
function g() internal virtual override { }
|
||||
}
|
||||
// ----
|
||||
// Warning 6321: (52-56): Unnamed return variable can remain unassigned when the function is called when "C" is the most derived contract. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (181-185): Unnamed return variable can remain unassigned when the function is called when "C" is the most derived contract. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (318-322): 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,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.
|
||||
-1
@@ -5,4 +5,3 @@ contract C {
|
||||
}
|
||||
}
|
||||
// ----
|
||||
// Warning 6321: (46-50): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
|
||||
-4
@@ -10,8 +10,4 @@ contract C {
|
||||
function h() internal pure returns (bytes memory, string storage s) { s = s; }
|
||||
}
|
||||
// ----
|
||||
// Warning 6321: (51-55): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (57-61): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (63-67): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (69-73): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
// Warning 6321: (250-262): Unnamed return variable can remain unassigned. Add an explicit return with value to all non-reverting code paths or name the variable.
|
||||
|
||||
@@ -5,4 +5,3 @@ contract C {
|
||||
function i() payable public { i(); h(); g(); f(); }
|
||||
}
|
||||
// ----
|
||||
// Warning 6321: (89-93): 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