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:
@@ -63,21 +63,21 @@ bool StaticAnalyzer::visit(FunctionDefinition const& _function)
|
||||
|
||||
void StaticAnalyzer::endVisit(FunctionDefinition const&)
|
||||
{
|
||||
m_currentFunction = nullptr;
|
||||
m_constructor = false;
|
||||
for (auto const& var: m_localVarUseCount)
|
||||
if (var.second == 0)
|
||||
{
|
||||
if (var.first.second->isCallableParameter())
|
||||
m_errorReporter.warning(
|
||||
var.first.second->location(),
|
||||
"Unused function parameter. Remove or comment out the variable name to silence this warning."
|
||||
);
|
||||
else
|
||||
m_errorReporter.warning(var.first.second->location(), "Unused local variable.");
|
||||
}
|
||||
|
||||
if (m_currentFunction && !m_currentFunction->body().statements().empty())
|
||||
for (auto const& var: m_localVarUseCount)
|
||||
if (var.second == 0)
|
||||
{
|
||||
if (var.first.second->isCallableParameter())
|
||||
m_errorReporter.warning(
|
||||
var.first.second->location(),
|
||||
"Unused function parameter. Remove or comment out the variable name to silence this warning."
|
||||
);
|
||||
else
|
||||
m_errorReporter.warning(var.first.second->location(), "Unused local variable.");
|
||||
}
|
||||
m_localVarUseCount.clear();
|
||||
m_constructor = false;
|
||||
m_currentFunction = nullptr;
|
||||
}
|
||||
|
||||
bool StaticAnalyzer::visit(Identifier const& _identifier)
|
||||
|
||||
Reference in New Issue
Block a user