diff options
author | Erik Kundt <bitshift@posteo.org> | 2018-07-27 03:45:24 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2018-09-04 00:35:57 +0800 |
commit | 75a92b0ffd0946c17a27a58e6e02abe96cd3fa00 (patch) | |
tree | 3a7c0b7e11942266eed23e7b2a0259fd5db1a56c /libsolidity/analysis/ViewPureChecker.h | |
parent | 378f69160884ba23f6876d57a3eb6425bfa1d2cf (diff) | |
download | dexon-solidity-75a92b0ffd0946c17a27a58e6e02abe96cd3fa00.tar.gz dexon-solidity-75a92b0ffd0946c17a27a58e6e02abe96cd3fa00.tar.zst dexon-solidity-75a92b0ffd0946c17a27a58e6e02abe96cd3fa00.zip |
Warns if modifier uses msg.value in non-payable function.
Diffstat (limited to 'libsolidity/analysis/ViewPureChecker.h')
-rw-r--r-- | libsolidity/analysis/ViewPureChecker.h | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/libsolidity/analysis/ViewPureChecker.h b/libsolidity/analysis/ViewPureChecker.h index 3db52e7e..faa5b698 100644 --- a/libsolidity/analysis/ViewPureChecker.h +++ b/libsolidity/analysis/ViewPureChecker.h @@ -31,16 +31,6 @@ namespace dev namespace solidity { -class ASTNode; -class FunctionDefinition; -class ModifierDefinition; -class Identifier; -class MemberAccess; -class IndexAccess; -class ModifierInvocation; -class FunctionCall; -class InlineAssembly; - class ViewPureChecker: private ASTConstVisitor { public: @@ -50,6 +40,11 @@ public: bool check(); private: + struct MutabilityAndLocation + { + StateMutability mutability; + SourceLocation location; + }; virtual bool visit(FunctionDefinition const& _funDef) override; virtual void endVisit(FunctionDefinition const& _funDef) override; @@ -65,15 +60,19 @@ private: /// Called when an element of mutability @a _mutability is encountered. /// Creates appropriate warnings and errors and sets @a m_currentBestMutability. - void reportMutability(StateMutability _mutability, SourceLocation const& _location); + void reportMutability( + StateMutability _mutability, + SourceLocation const& _location, + boost::optional<SourceLocation> const& _nestedLocation = {} + ); std::vector<std::shared_ptr<ASTNode>> const& m_ast; ErrorReporter& m_errorReporter; bool m_errors = false; - StateMutability m_currentBestMutability = StateMutability::Payable; + MutabilityAndLocation m_bestMutabilityAndLocation = MutabilityAndLocation{StateMutability::Payable, SourceLocation()}; FunctionDefinition const* m_currentFunction = nullptr; - std::map<ModifierDefinition const*, StateMutability> m_inferredMutability; + std::map<ModifierDefinition const*, MutabilityAndLocation> m_inferredMutability; }; } |