diff options
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/analysis/StaticAnalyzer.cpp | 7 | ||||
-rw-r--r-- | libsolidity/analysis/StaticAnalyzer.h | 2 | ||||
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 4 |
3 files changed, 11 insertions, 2 deletions
diff --git a/libsolidity/analysis/StaticAnalyzer.cpp b/libsolidity/analysis/StaticAnalyzer.cpp index c39f874e..df7f6e88 100644 --- a/libsolidity/analysis/StaticAnalyzer.cpp +++ b/libsolidity/analysis/StaticAnalyzer.cpp @@ -57,6 +57,13 @@ void StaticAnalyzer::endVisit(FunctionDefinition const&) m_nonPayablePublic = false; } +bool StaticAnalyzer::visit(ExpressionStatement const& _statement) +{ + if (_statement.expression().annotation().isPure) + warning(_statement.location(), "Statement has no effects."); + return true; +} + bool StaticAnalyzer::visit(MemberAccess const& _memberAccess) { if (m_nonPayablePublic && !m_library) diff --git a/libsolidity/analysis/StaticAnalyzer.h b/libsolidity/analysis/StaticAnalyzer.h index 0cb961bd..84342322 100644 --- a/libsolidity/analysis/StaticAnalyzer.h +++ b/libsolidity/analysis/StaticAnalyzer.h @@ -60,6 +60,8 @@ private: virtual bool visit(FunctionDefinition const& _function) override; virtual void endVisit(FunctionDefinition const& _function) override; + virtual bool visit(ExpressionStatement const& _statement) override; + virtual bool visit(MemberAccess const& _memberAccess) override; ErrorList& m_errors; diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index dc04404d..b37db7b7 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1674,8 +1674,8 @@ bool TypeChecker::visit(Identifier const& _identifier) if (auto variableDeclaration = dynamic_cast<VariableDeclaration const*>(annotation.referencedDeclaration)) annotation.isPure = annotation.isConstant = variableDeclaration->isConstant(); else if (dynamic_cast<MagicVariableDeclaration const*>(annotation.referencedDeclaration)) - if (auto functionType = dynamic_cast<FunctionType const*>(annotation.type.get())) - annotation.isPure = functionType->isPure(); + if (dynamic_cast<FunctionType const*>(annotation.type.get())) + annotation.isPure = true; return false; } |