summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp5
-rw-r--r--clang/unittests/Format/FormatTest.cpp1
2 files changed, 4 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 99e58321cd7..425e15b81f9 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -52,8 +52,8 @@ bool UnwrappedLineParser::parseLevel() {
addUnwrappedLine();
break;
case tok::r_brace:
- // FIXME: We need a test when it has to be "return Error;"
- return false;
+ // Stray '}' is an error.
+ return true;
default:
parseStatement();
break;
@@ -63,6 +63,7 @@ bool UnwrappedLineParser::parseLevel() {
}
bool UnwrappedLineParser::parseBlock() {
+ assert(FormatTok.Tok.is(tok::l_brace) && "'{' expected");
nextToken();
// FIXME: Remove this hack to handle namespaces.
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index a2a37cf1a70..c385e353d69 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -428,6 +428,7 @@ TEST_F(FormatTest, IncorrectCodeErrorDetection) {
EXPECT_EQ("{\n{\n}\n", format("{\n{\n}\n"));
EXPECT_EQ("{\n {\n}\n", format("{\n {\n}\n"));
EXPECT_EQ("{\n {\n }\n", format("{\n {\n }\n"));
+ EXPECT_EQ("{\n {\n }\n }\n}\n", format("{\n {\n }\n }\n}\n"));
FormatStyle Style = getLLVMStyle();
Style.ColumnLimit = 10;
OpenPOWER on IntegriCloud