From eaab71294476f46513678be2e8cad02589d141dc Mon Sep 17 00:00:00 2001 From: Yoichi Hirai Date: Wed, 30 Nov 2016 17:28:07 +0100 Subject: [PATCH] parser: recognize an end of comment of the form `**/` at the end of a multi-line doc comment This fixes #1433 --- libsolidity/parsing/Scanner.cpp | 7 ++++++- test/libsolidity/SolidityParser.cpp | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/libsolidity/parsing/Scanner.cpp b/libsolidity/parsing/Scanner.cpp index 6115101e6..3623f23f7 100644 --- a/libsolidity/parsing/Scanner.cpp +++ b/libsolidity/parsing/Scanner.cpp @@ -327,7 +327,12 @@ Token::Value Scanner::scanMultiLineDocComment() if (isLineTerminator(m_char)) { skipWhitespace(); - if (!m_source.isPastEndOfInput(1) && m_source.get(0) == '*' && m_source.get(1) != '/') + if (!m_source.isPastEndOfInput(1) && m_source.get(0) == '*' && m_source.get(1) == '*') + { // it is unknown if this leads to the end of the comment + addCommentLiteralChar('*'); + advance(); + } + else if (!m_source.isPastEndOfInput(1) && m_source.get(0) == '*' && m_source.get(1) != '/') { // skip first '*' in subsequent lines if (charsAdded) addCommentLiteralChar('\n'); diff --git a/test/libsolidity/SolidityParser.cpp b/test/libsolidity/SolidityParser.cpp index a3217f08e..1c616ef66 100644 --- a/test/libsolidity/SolidityParser.cpp +++ b/test/libsolidity/SolidityParser.cpp @@ -962,6 +962,19 @@ BOOST_AUTO_TEST_CASE(empty_comment) BOOST_CHECK(successParse(text)); } +BOOST_AUTO_TEST_CASE(comment_end_with_double_star) +{ + char const* text = R"( + contract C1 { + /** + **/ + } + contract C2 {} + )"; + BOOST_CHECK(successParse(text)); +} + + BOOST_AUTO_TEST_CASE(library_simple) { char const* text = R"(