summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp2
-rw-r--r--clang/unittests/Format/FormatTest.cpp3
2 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 2ca44620c33..a01344c03e6 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -684,7 +684,7 @@ void UnwrappedLineParser::parseRecord() {
// (this would still leave us with an ambiguity between template function
// and class declarations).
if (FormatTok.Tok.is(tok::colon) || FormatTok.Tok.is(tok::less)) {
- while (FormatTok.Tok.isNot(tok::l_brace)) {
+ while (!eof() && FormatTok.Tok.isNot(tok::l_brace)) {
if (FormatTok.Tok.is(tok::semi))
return;
nextToken();
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 40f09539e7a..2a3d66dfd79 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2544,6 +2544,9 @@ TEST_F(FormatTest, UnderstandContextOfRecordTypeKeywords) {
" class X x;\n"
"else\n"
" f();\n");
+
+ // This is simply incomplete. Formatting is not important, but must not crash.
+ verifyFormat("class A:");
}
TEST_F(FormatTest, DoNotInterfereWithErrorAndWarning) {
OpenPOWER on IntegriCloud