aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libsolidity/Parser.cpp7
-rw-r--r--libsolidity/Scanner.cpp4
-rw-r--r--test/libsolidity/SolidityNatspecJSON.cpp16
-rw-r--r--test/libsolidity/SolidityParser.cpp10
-rw-r--r--test/libsolidity/SolidityScanner.cpp10
5 files changed, 43 insertions, 4 deletions
diff --git a/libsolidity/Parser.cpp b/libsolidity/Parser.cpp
index e001d0f1..7f779ed0 100644
--- a/libsolidity/Parser.cpp
+++ b/libsolidity/Parser.cpp
@@ -69,7 +69,7 @@ ASTPointer<SourceUnit> Parser::parse(shared_ptr<Scanner> const& _scanner)
m_scanner = _scanner;
ASTNodeFactory nodeFactory(*this);
vector<ASTPointer<ASTNode>> nodes;
- while (_scanner->currentToken() != Token::EOS)
+ while (m_scanner->currentToken() != Token::EOS)
{
switch (m_scanner->currentToken())
{
@@ -1076,8 +1076,9 @@ ASTPointer<ParameterList> Parser::createEmptyParameterList()
ParserError Parser::createParserError(string const& _description) const
{
- return ParserError() << errinfo_sourceLocation(SourceLocation(position(), position(), sourceName()))
- << errinfo_comment(_description);
+ return ParserError() <<
+ errinfo_sourceLocation(SourceLocation(position(), position(), sourceName())) <<
+ errinfo_comment(_description);
}
diff --git a/libsolidity/Scanner.cpp b/libsolidity/Scanner.cpp
index 374f78e4..d67b6423 100644
--- a/libsolidity/Scanner.cpp
+++ b/libsolidity/Scanner.cpp
@@ -224,7 +224,9 @@ Token::Value Scanner::skipSingleLineComment()
// to be part of the single-line comment; it is recognized
// separately by the lexical grammar and becomes part of the
// stream of input elements for the syntactic grammar
- while (advance() && !isLineTerminator(m_char)) { };
+ while (!isLineTerminator(m_char))
+ if (!advance()) break;
+
return Token::Whitespace;
}
diff --git a/test/libsolidity/SolidityNatspecJSON.cpp b/test/libsolidity/SolidityNatspecJSON.cpp
index 8a133f5f..5d20fe7b 100644
--- a/test/libsolidity/SolidityNatspecJSON.cpp
+++ b/test/libsolidity/SolidityNatspecJSON.cpp
@@ -527,6 +527,22 @@ BOOST_AUTO_TEST_CASE(natspec_multiline_notice_without_tag)
checkNatspec(sourceCode, natspec, true);
}
+BOOST_AUTO_TEST_CASE(empty_comment)
+{
+ char const* sourceCode = R"(
+ //
+ contract test
+ {}
+ )";
+ char const* natspec = R"ABCDEF(
+ {
+ "methods" : {}
+ }
+ )ABCDEF";
+
+ checkNatspec(sourceCode, natspec, true);
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp
index 3cb5aa4b..14b9e9e4 100644
--- a/test/libsolidity/SolidityParser.cpp
+++ b/test/libsolidity/SolidityParser.cpp
@@ -914,6 +914,16 @@ BOOST_AUTO_TEST_CASE(location_specifiers_with_var)
BOOST_CHECK_THROW(parseText(text), ParserError);
}
+BOOST_AUTO_TEST_CASE(empty_comment)
+{
+ char const* text = R"(
+ //
+ contract test
+ {}
+ )";
+ BOOST_CHECK_NO_THROW(parseText(text));
+}
+
BOOST_AUTO_TEST_SUITE_END()
}
diff --git a/test/libsolidity/SolidityScanner.cpp b/test/libsolidity/SolidityScanner.cpp
index 431f233e..dadcd903 100644
--- a/test/libsolidity/SolidityScanner.cpp
+++ b/test/libsolidity/SolidityScanner.cpp
@@ -281,6 +281,16 @@ BOOST_AUTO_TEST_CASE(time_after)
BOOST_CHECK_EQUAL(scanner.currentToken(), Token::After);
}
+BOOST_AUTO_TEST_CASE(empty_comment)
+{
+ Scanner scanner(CharStream("//\ncontract{}"));
+ BOOST_CHECK_EQUAL(scanner.currentCommentLiteral(), "");
+ BOOST_CHECK_EQUAL(scanner.currentToken(), Token::Contract);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::LBrace);
+ BOOST_CHECK_EQUAL(scanner.next(), Token::RBrace);
+
+}
+
BOOST_AUTO_TEST_SUITE_END()
}