mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Disable unused var warning for functions with empty body
This commit is contained in:
parent
85291bcb2d
commit
53537864a2
@ -63,21 +63,21 @@ bool StaticAnalyzer::visit(FunctionDefinition const& _function)
|
|||||||
|
|
||||||
void StaticAnalyzer::endVisit(FunctionDefinition const&)
|
void StaticAnalyzer::endVisit(FunctionDefinition const&)
|
||||||
{
|
{
|
||||||
m_currentFunction = nullptr;
|
if (m_currentFunction && !m_currentFunction->body().statements().empty())
|
||||||
m_constructor = false;
|
for (auto const& var: m_localVarUseCount)
|
||||||
for (auto const& var: m_localVarUseCount)
|
if (var.second == 0)
|
||||||
if (var.second == 0)
|
{
|
||||||
{
|
if (var.first.second->isCallableParameter())
|
||||||
if (var.first.second->isCallableParameter())
|
m_errorReporter.warning(
|
||||||
m_errorReporter.warning(
|
var.first.second->location(),
|
||||||
var.first.second->location(),
|
"Unused function parameter. Remove or comment out the variable name to silence this warning."
|
||||||
"Unused function parameter. Remove or comment out the variable name to silence this warning."
|
);
|
||||||
);
|
else
|
||||||
else
|
m_errorReporter.warning(var.first.second->location(), "Unused local variable.");
|
||||||
m_errorReporter.warning(var.first.second->location(), "Unused local variable.");
|
}
|
||||||
}
|
|
||||||
|
|
||||||
m_localVarUseCount.clear();
|
m_localVarUseCount.clear();
|
||||||
|
m_constructor = false;
|
||||||
|
m_currentFunction = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StaticAnalyzer::visit(Identifier const& _identifier)
|
bool StaticAnalyzer::visit(Identifier const& _identifier)
|
||||||
|
@ -7,5 +7,4 @@ contract Test {
|
|||||||
function g (C c) external {}
|
function g (C c) external {}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (125-128): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (113-141): Function state mutability can be restricted to pure
|
// Warning: (113-141): Function state mutability can be restricted to pure
|
||||||
|
@ -9,5 +9,4 @@ contract Test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (68-71): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (56-82): Function state mutability can be restricted to pure
|
// Warning: (56-82): Function state mutability can be restricted to pure
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
contract B { function f() public {} }
|
contract B { function f() public {} }
|
||||||
contract C is B { function f(uint i) public {} }
|
contract C is B { function f(uint i) public {} }
|
||||||
// ----
|
// ----
|
||||||
// Warning: (67-73): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (13-35): Function state mutability can be restricted to pure
|
// Warning: (13-35): Function state mutability can be restricted to pure
|
||||||
// Warning: (56-84): Function state mutability can be restricted to pure
|
// Warning: (56-84): Function state mutability can be restricted to pure
|
||||||
|
@ -2,6 +2,5 @@ contract A { function f(uint a) public {} }
|
|||||||
contract B { function f() public {} }
|
contract B { function f() public {} }
|
||||||
contract C is A, B { }
|
contract C is A, B { }
|
||||||
// ----
|
// ----
|
||||||
// Warning: (24-30): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (13-41): Function state mutability can be restricted to pure
|
// Warning: (13-41): Function state mutability can be restricted to pure
|
||||||
// Warning: (57-79): Function state mutability can be restricted to pure
|
// Warning: (57-79): Function state mutability can be restricted to pure
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
contract A { constructor(uint a) public { } }
|
contract A { constructor(uint a) public { } }
|
||||||
contract B is A { }
|
contract B is A { }
|
||||||
// ----
|
// ----
|
||||||
// Warning: (25-31): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
contract A { constructor(uint a) public { } }
|
contract A { constructor(uint a) public { } }
|
||||||
contract B is A { }
|
contract B is A { }
|
||||||
// ----
|
// ----
|
||||||
// Warning: (25-31): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
|
@ -6,5 +6,4 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (91-106): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (80-122): Function state mutability can be restricted to pure
|
// Warning: (80-122): Function state mutability can be restricted to pure
|
||||||
|
@ -3,4 +3,3 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (28-34): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
|
@ -3,4 +3,3 @@ contract C {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (51-57): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
|
@ -3,7 +3,4 @@ contract test {
|
|||||||
function functionName(bytes20 arg1, address addr) public view returns (int id) { }
|
function functionName(bytes20 arg1, address addr) public view returns (int id) { }
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (58-70): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (72-84): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (107-113): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (36-118): Function state mutability can be restricted to pure
|
// Warning: (36-118): Function state mutability can be restricted to pure
|
||||||
|
@ -4,6 +4,4 @@ contract test {
|
|||||||
function functionName(bytes32 input) public returns (bytes32 out) {}
|
function functionName(bytes32 input) public returns (bytes32 out) {}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (128-139): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (75-143): Function state mutability can be restricted to pure
|
// Warning: (75-143): Function state mutability can be restricted to pure
|
||||||
|
@ -3,7 +3,4 @@ contract test {
|
|||||||
function (uint, uint) internal returns (uint) f1 = f;
|
function (uint, uint) internal returns (uint) f1 = f;
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (63-69): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (20-73): Function state mutability can be restricted to pure
|
// Warning: (20-73): Function state mutability can be restricted to pure
|
||||||
|
@ -5,9 +5,6 @@ contract test {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (31-37): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (39-45): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (63-69): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (108-156): Unused local variable.
|
// Warning: (108-156): Unused local variable.
|
||||||
// Warning: (20-73): Function state mutability can be restricted to pure
|
// Warning: (20-73): Function state mutability can be restricted to pure
|
||||||
// Warning: (78-167): Function state mutability can be restricted to pure
|
// Warning: (78-167): Function state mutability can be restricted to pure
|
||||||
|
@ -10,14 +10,6 @@ contract test {
|
|||||||
function functionName4(bytes32 input) public returns (bytes32 out) {}
|
function functionName4(bytes32 input) public returns (bytes32 out) {}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (97-110): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (128-139): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (203-216): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (234-245): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (304-317): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (335-346): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (410-423): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (441-452): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (74-143): Function state mutability can be restricted to pure
|
// Warning: (74-143): Function state mutability can be restricted to pure
|
||||||
// Warning: (180-249): 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: (281-350): Function state mutability can be restricted to pure
|
||||||
|
@ -3,6 +3,4 @@ contract test {
|
|||||||
function functionName(bytes32 input) public returns (bytes32 out) {}
|
function functionName(bytes32 input) public returns (bytes32 out) {}
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
// Warning: (58-71): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (89-100): Unused function parameter. Remove or comment out the variable name to silence this warning.
|
|
||||||
// Warning: (36-104): Function state mutability can be restricted to pure
|
// Warning: (36-104): Function state mutability can be restricted to pure
|
||||||
|
Loading…
Reference in New Issue
Block a user