case tok::kw_enum:
parseEnum();
return;
- case tok::kw_struct: // fallthrough
- case tok::kw_union: // fallthrough
+ case tok::kw_struct:
+ case tok::kw_union:
case tok::kw_class:
parseRecord();
// A record declaration or definition is always the start of a structural
nextToken();
addUnwrappedLine();
return;
+ case tok::r_brace:
+ addUnwrappedLine();
+ return;
case tok::l_paren:
parseParens();
break;
//===----------------------------------------------------------------------===//
TEST_F(FormatTest, IncorrectCodeTrailingStuff) {
- verifyFormat("void f() { return } 42");
+ verifyFormat("void f() { return }\n42");
+ verifyFormat("void f() {\n"
+ " if (0)\n"
+ " return\n"
+ "}\n"
+ "42");
+}
+
+TEST_F(FormatTest, IncorrectCodeMissingSemicolon) {
+ EXPECT_EQ("void f() { return }", format("void f ( ) { return }"));
+ EXPECT_EQ("void f() {\n"
+ " if (a)\n"
+ " return\n"
+ "}", format("void f ( ) { if ( a ) return }"));
+ EXPECT_EQ("namespace N { void f() }", format("namespace N { void f() }"));
+ EXPECT_EQ("namespace N {\n"
+ "void f() {}\n"
+ "void g()\n"
+ "}", format("namespace N { void f( ) { } void g( ) }"));
}
TEST_F(FormatTest, IndentationWithinColumnLimitNotPossible) {