diff options
Diffstat (limited to 'libsolidity/analysis/StaticAnalyzer.cpp')
-rw-r--r-- | libsolidity/analysis/StaticAnalyzer.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index 375e9bde..46477e1e 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -38,12 +38,14 @@ bool StaticAnalyzer::analyze(SourceUnit const& _sourceUnit) bool StaticAnalyzer::visit(ContractDefinition const& _contract) { m_library = _contract.isLibrary(); + m_currentContract = &_contract; return true; } void StaticAnalyzer::endVisit(ContractDefinition const&) { m_library = false; + m_currentContract = nullptr; } bool StaticAnalyzer::visit(FunctionDefinition const& _function) @@ -54,6 +56,7 @@ bool StaticAnalyzer::visit(FunctionDefinition const& _function) solAssert(!m_currentFunction, ""); solAssert(m_localVarUseCount.empty(), ""); m_nonPayablePublic = _function.isPublic() && !_function.isPayable(); + m_constructor = _function.isConstructor(); return true; } @@ -61,6 +64,7 @@ void StaticAnalyzer::endVisit(FunctionDefinition const&) { m_currentFunction = nullptr; m_nonPayablePublic = false; + m_constructor = false; for (auto const& var: m_localVarUseCount) if (var.second == 0) m_errorReporter.warning(var.first->location(), "Unused local variable"); @@ -123,6 +127,19 @@ bool StaticAnalyzer::visit(MemberAccess const& _memberAccess) "\"msg.value\" used in non-payable function. Do you want to add the \"payable\" modifier to this function?" ); + if (_memberAccess.memberName() == "callcode") + if (auto const* type = dynamic_cast<FunctionType const*>(_memberAccess.annotation().type.get())) + if (type->kind() == FunctionType::Kind::BareCallCode) + m_errorReporter.warning( + _memberAccess.location(), + "\"callcode\" has been deprecated in favour of \"delegatecall\"." + ); + + if (m_constructor && m_currentContract) + if (ContractType const* type = dynamic_cast<ContractType const*>(_memberAccess.expression().annotation().type.get())) + if (type->contractDefinition() == *m_currentContract) + m_errorReporter.warning(_memberAccess.location(), "\"this\" used in constructor."); + return true; } |