aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeonardo Alt <leo@ethereum.org>2018-09-04 18:14:04 +0800
committerLeonardo Alt <leo@ethereum.org>2018-09-04 18:14:04 +0800
commitac8892e0e3ab4e0152ba74c5857b79aec54e7f1b (patch)
tree7581e63ed4183d6132ea65ee759f2b08180852c4
parent17176871ab4903498be0f9d62997ca1a9ace04d8 (diff)
downloaddexon-solidity-ac8892e0e3ab4e0152ba74c5857b79aec54e7f1b.tar.gz
dexon-solidity-ac8892e0e3ab4e0152ba74c5857b79aec54e7f1b.tar.zst
dexon-solidity-ac8892e0e3ab4e0152ba74c5857b79aec54e7f1b.zip
Review suggestions
-rw-r--r--Changelog.md2
-rw-r--r--libsolidity/analysis/SyntaxChecker.cpp14
-rw-r--r--libsolidity/analysis/SyntaxChecker.h8
3 files changed, 12 insertions, 12 deletions
diff --git a/Changelog.md b/Changelog.md
index ec494c41..c9d80432 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -68,7 +68,7 @@ Breaking Changes:
* Syntax Checker: Named return values in function types are an error.
* Syntax Checker: Strictly require visibility specifier for functions. This was already the case in the experimental 0.5.0 mode.
* Syntax Checker: Disallow unary ``+``. This was already the case in the experimental 0.5.0 mode.
- * Syntax Checker: Disallow single statement variable declaration inside if/while/for without a block.
+ * Syntax Checker: Disallow single statement variable declaration inside if/while/for bodies that are not blocks.
* View Pure Checker: Strictly enfore state mutability. This was already the case in the experimental 0.5.0 mode.
Language Features:
diff --git a/libsolidity/analysis/SyntaxChecker.cpp b/libsolidity/analysis/SyntaxChecker.cpp
index ab883a21..0bc20f2e 100644
--- a/libsolidity/analysis/SyntaxChecker.cpp
+++ b/libsolidity/analysis/SyntaxChecker.cpp
@@ -138,25 +138,25 @@ void SyntaxChecker::endVisit(ModifierDefinition const& _modifier)
m_placeholderFound = false;
}
-void SyntaxChecker::checkSingleStatementVariableDeclaration(ASTNode const* _statement)
+void SyntaxChecker::checkSingleStatementVariableDeclaration(ASTNode const& _statement)
{
- auto varDecl = dynamic_cast<VariableDeclarationStatement const*>(_statement);
+ auto varDecl = dynamic_cast<VariableDeclarationStatement const*>(&_statement);
if (varDecl)
- m_errorReporter.syntaxError(_statement->location(), "Variable declarations can only be used inside blocks.");
+ m_errorReporter.syntaxError(_statement.location(), "Variable declarations can only be used inside blocks.");
}
bool SyntaxChecker::visit(IfStatement const& _ifStatement)
{
- checkSingleStatementVariableDeclaration(&_ifStatement.trueStatement());
+ checkSingleStatementVariableDeclaration(_ifStatement.trueStatement());
if (Statement const* _statement = _ifStatement.falseStatement())
- checkSingleStatementVariableDeclaration(_statement);
+ checkSingleStatementVariableDeclaration(*_statement);
return true;
}
bool SyntaxChecker::visit(WhileStatement const& _whileStatement)
{
m_inLoopDepth++;
- checkSingleStatementVariableDeclaration(&_whileStatement.body());
+ checkSingleStatementVariableDeclaration(_whileStatement.body());
return true;
}
@@ -168,7 +168,7 @@ void SyntaxChecker::endVisit(WhileStatement const&)
bool SyntaxChecker::visit(ForStatement const& _forStatement)
{
m_inLoopDepth++;
- checkSingleStatementVariableDeclaration(&_forStatement.body());
+ checkSingleStatementVariableDeclaration(_forStatement.body());
return true;
}
diff --git a/libsolidity/analysis/SyntaxChecker.h b/libsolidity/analysis/SyntaxChecker.h
index 27d98401..f5716bf9 100644
--- a/libsolidity/analysis/SyntaxChecker.h
+++ b/libsolidity/analysis/SyntaxChecker.h
@@ -52,10 +52,10 @@ private:
virtual bool visit(ModifierDefinition const& _modifier) override;
virtual void endVisit(ModifierDefinition const& _modifier) override;
- // Reports an error if _statement is a VariableDeclarationStatement.
- // Used by if/while/for to check for single statement variable declarations
- // without a block.
- void checkSingleStatementVariableDeclaration(ASTNode const* _statement);
+ /// Reports an error if _statement is a VariableDeclarationStatement.
+ /// Used by if/while/for to check for single statement variable declarations
+ /// without a block.
+ void checkSingleStatementVariableDeclaration(ASTNode const& _statement);
virtual bool visit(IfStatement const& _ifStatement) override;
virtual bool visit(WhileStatement const& _whileStatement) override;