Disable state mutability warning for functions with empty body

This commit is contained in:
Leonardo Alt 2018-12-12 12:03:59 +01:00
parent 53537864a2
commit 508aae8a67
32 changed files with 1 additions and 45 deletions

View File

@ -156,6 +156,7 @@ void ViewPureChecker::endVisit(FunctionDefinition const& _funDef)
m_bestMutabilityAndLocation.mutability < _funDef.stateMutability() &&
_funDef.stateMutability() != StateMutability::Payable &&
_funDef.isImplemented() &&
!_funDef.body().statements().empty() &&
!_funDef.isConstructor() &&
!_funDef.isFallback() &&
!_funDef.annotation().superFunction

View File

@ -18,9 +18,3 @@ contract test {
function(uint) pure internal h = fh;
}
// ----
// Warning: (20-47): Function state mutability can be restricted to pure
// Warning: (52-81): Function state mutability can be restricted to pure
// Warning: (86-115): Function state mutability can be restricted to pure
// Warning: (120-149): Function state mutability can be restricted to pure
// Warning: (154-183): Function state mutability can be restricted to pure
// Warning: (188-217): Function state mutability can be restricted to pure

View File

@ -3,4 +3,3 @@ contract test {
function f() public {}
}
// ----
// Warning: (53-75): Function state mutability can be restricted to pure

View File

@ -3,4 +3,3 @@ contract test {
function g(uint256, bool) public returns (uint256) { }
}
// ----
// Warning: (88-142): Function state mutability can be restricted to pure

View File

@ -7,4 +7,3 @@ contract Test {
function g (C c) external {}
}
// ----
// Warning: (113-141): Function state mutability can be restricted to pure

View File

@ -9,4 +9,3 @@ contract Test {
}
}
// ----
// Warning: (56-82): Function state mutability can be restricted to pure

View File

@ -5,5 +5,3 @@ contract derived is root, inter2, inter1 {
function g() public { f(); rootFunction(); }
}
// ----
// Warning: (16-49): Function state mutability can be restricted to pure
// Warning: (129-151): Function state mutability can be restricted to pure

View File

@ -1,5 +1,3 @@
contract B { function f() public {} }
contract C is B { function f(uint i) public {} }
// ----
// Warning: (13-35): Function state mutability can be restricted to pure
// Warning: (56-84): Function state mutability can be restricted to pure

View File

@ -2,5 +2,3 @@ contract A { function f(uint a) public {} }
contract B { function f() public {} }
contract C is A, B { }
// ----
// Warning: (13-41): Function state mutability can be restricted to pure
// Warning: (57-79): Function state mutability can be restricted to pure

View File

@ -3,4 +3,3 @@ contract B { function f() public {} function g() public returns (uint8) {} }
contract C is A, B { }
// ----
// Warning: (35-42): Unused local variable.
// Warning: (95-133): Function state mutability can be restricted to pure

View File

@ -5,4 +5,3 @@ contract d {
function g() public { c(0).f(); }
}
// ----
// Warning: (17-39): Function state mutability can be restricted to pure

View File

@ -2,4 +2,3 @@ contract test {
function f(uint) public { }
}
// ----
// Warning: (20-47): Function state mutability can be restricted to pure

View File

@ -2,4 +2,3 @@ contract test {
function f() public returns (bool) { }
}
// ----
// Warning: (20-58): Function state mutability can be restricted to pure

View File

@ -6,4 +6,3 @@ contract C {
}
}
// ----
// Warning: (80-122): Function state mutability can be restricted to pure

View File

@ -11,4 +11,3 @@ contract C {
}
}
// ----
// Warning: (128-189): Function state mutability can be restricted to pure

View File

@ -5,4 +5,3 @@ library c {
}
// ----
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
// Warning: (75-116): Function state mutability can be restricted to pure

View File

@ -85,7 +85,5 @@ contract C {
}
// ----
// Warning: (1005-1019): This declaration shadows an existing declaration.
// Warning: (90-116): Function state mutability can be restricted to pure
// Warning: (121-147): Function state mutability can be restricted to pure
// Warning: (257-642): Function state mutability can be restricted to pure
// Warning: (647-1227): Function state mutability can be restricted to pure

View File

@ -5,4 +5,3 @@ contract test {
}
}
// ----
// Warning: (20-57): Function state mutability can be restricted to pure

View File

@ -10,4 +10,3 @@ contract test {
}
}
// ----
// Warning: (122-151): Function state mutability can be restricted to pure

View File

@ -7,4 +7,3 @@ contract C {
}
// ----
// Warning: (0-33): Experimental features are turned on. Do not use experimental features on live deployments.
// Warning: (112-164): Function state mutability can be restricted to pure

View File

@ -3,4 +3,3 @@ contract test {
function functionName(bytes20 arg1, address addr) public view returns (int id) { }
}
// ----
// Warning: (36-118): Function state mutability can be restricted to pure

View File

@ -2,4 +2,3 @@ contract c {
function x() external {}
}
// ----
// Warning: (17-41): Function state mutability can be restricted to pure

View File

@ -4,4 +4,3 @@ contract test {
function functionName(bytes32 input) public returns (bytes32 out) {}
}
// ----
// Warning: (75-143): Function state mutability can be restricted to pure

View File

@ -3,4 +3,3 @@ contract test {
function (uint, uint) internal returns (uint) f1 = f;
}
// ----
// Warning: (20-73): Function state mutability can be restricted to pure

View File

@ -6,5 +6,4 @@ contract test {
}
// ----
// Warning: (108-156): Unused local variable.
// Warning: (20-73): Function state mutability can be restricted to pure
// Warning: (78-167): Function state mutability can be restricted to pure

View File

@ -2,4 +2,3 @@ library Lib {
function f() public { }
}
// ----
// Warning: (18-41): Function state mutability can be restricted to pure

View File

@ -4,4 +4,3 @@ contract c {
function f() public mod1(7) mod2 { }
}
// ----
// Warning: (135-171): Function state mutability can be restricted to view

View File

@ -10,7 +10,3 @@ contract test {
function functionName4(bytes32 input) public returns (bytes32 out) {}
}
// ----
// Warning: (74-143): Function state mutability can be restricted to pure
// Warning: (180-249): Function state mutability can be restricted to pure
// Warning: (281-350): Function state mutability can be restricted to pure
// Warning: (387-456): Function state mutability can be restricted to pure

View File

@ -3,4 +3,3 @@ contract test {
function functionName() public {}
}
// ----
// Warning: (36-69): Function state mutability can be restricted to pure

View File

@ -3,4 +3,3 @@ contract test {
function functionName(bytes32 input) public returns (bytes32 out) {}
}
// ----
// Warning: (36-104): Function state mutability can be restricted to pure

View File

@ -9,6 +9,3 @@ contract c {
}
// ----
// Warning: (58-71): This declaration shadows an existing declaration.
// Warning: (89-111): Function state mutability can be restricted to pure
// Warning: (116-144): Function state mutability can be restricted to pure
// Warning: (149-182): Function state mutability can be restricted to pure

View File

@ -2,4 +2,3 @@ contract C {
function g() view public { }
}
// ----
// Warning: (17-45): Function state mutability can be restricted to pure