diff options
author | Leonardo Alt <leo@ethereum.org> | 2018-12-12 19:02:47 +0800 |
---|---|---|
committer | Leonardo Alt <leo@ethereum.org> | 2018-12-12 21:43:44 +0800 |
commit | 53537864a2b7322c58248ea8c9937d13aca7ca61 (patch) | |
tree | 1dc98be3121903626eec392a4e9caab74457522a /libsolidity | |
parent | 85291bcb2d0e92c8d515887a00174d46f974500d (diff) | |
download | dexon-solidity-53537864a2b7322c58248ea8c9937d13aca7ca61.tar.gz dexon-solidity-53537864a2b7322c58248ea8c9937d13aca7ca61.tar.zst dexon-solidity-53537864a2b7322c58248ea8c9937d13aca7ca61.zip |
Disable unused var warning for functions with empty body
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/analysis/StaticAnalyzer.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index 38391841..4d0f3461 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -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) |