diff options
author | chriseth <chris@ethereum.org> | 2017-05-02 22:43:47 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-02 22:43:47 +0800 |
commit | acab525fefe37f2c02478c79399d5c79e211434e (patch) | |
tree | 927dd8db8e5204452839da8e983d5457b6c7a935 /libsolidity/analysis | |
parent | 084ab4123f3b00ffba49f3ac5edcc58e0d79f0fb (diff) | |
parent | 96870686a9aba46a14d659c8c1cd107a9071857f (diff) | |
download | dexon-solidity-acab525fefe37f2c02478c79399d5c79e211434e.tar.gz dexon-solidity-acab525fefe37f2c02478c79399d5c79e211434e.tar.zst dexon-solidity-acab525fefe37f2c02478c79399d5c79e211434e.zip |
Merge pull request #2199 from roadriverrail/no_unary_plus
Deprecate use of unary '+'
Diffstat (limited to 'libsolidity/analysis')
-rw-r--r-- | libsolidity/analysis/SyntaxChecker.cpp | 17 | ||||
-rw-r--r-- | libsolidity/analysis/SyntaxChecker.h | 4 |
2 files changed, 21 insertions, 0 deletions
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp index 89014133..94e82a87 100644 --- a/libsolidity/analysis/SyntaxChecker.cpp +++ b/libsolidity/analysis/SyntaxChecker.cpp @@ -32,6 +32,16 @@ bool SyntaxChecker::checkSyntax(ASTNode const& _astRoot) return Error::containsOnlyWarnings(m_errors); } +void SyntaxChecker::warning(SourceLocation const& _location, string const& _description) +{ + auto err = make_shared<Error>(Error::Type::Warning); + *err << + errinfo_sourceLocation(_location) << + errinfo_comment(_description); + + m_errors.push_back(err); +} + void SyntaxChecker::syntaxError(SourceLocation const& _location, std::string const& _description) { auto err = make_shared<Error>(Error::Type::SyntaxError); @@ -148,6 +158,13 @@ bool SyntaxChecker::visit(Break const& _breakStatement) return true; } +bool SyntaxChecker::visit(UnaryOperation const& _operation) +{ + if (_operation.getOperator() == Token::Add) + warning(_operation.location(), "Use of unary + is deprecated."); + return true; +} + bool SyntaxChecker::visit(PlaceholderStatement const&) { m_placeholderFound = true; diff --git a/libsolidity/analysis/SyntaxChecker.h b/libsolidity/analysis/SyntaxChecker.h index 308e128b..8d7dcdd3 100644 --- a/libsolidity/analysis/SyntaxChecker.h +++ b/libsolidity/analysis/SyntaxChecker.h @@ -32,6 +32,7 @@ namespace solidity * The module that performs syntax analysis on the AST: * - whether continue/break is in a for/while loop. * - whether a modifier contains at least one '_' + * - issues deprecation warnings for unary '+' */ class SyntaxChecker: private ASTConstVisitor { @@ -43,6 +44,7 @@ public: private: /// Adds a new error to the list of errors. + void warning(SourceLocation const& _location, std::string const& _description); void syntaxError(SourceLocation const& _location, std::string const& _description); virtual bool visit(SourceUnit const& _sourceUnit) override; @@ -60,6 +62,8 @@ private: virtual bool visit(Continue const& _continueStatement) override; virtual bool visit(Break const& _breakStatement) override; + virtual bool visit(UnaryOperation const& _operation) override; + virtual bool visit(PlaceholderStatement const& _placeholderStatement) override; ErrorList& m_errors; |