Now we correctly parse and format:
verifyFormat("struct foo a = { bar };
int n;
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172229
91177308-0d34-0410-b5e6-
96231b3b80d8
return;
case tok::kw_struct: // fallthrough
case tok::kw_class:
- parseStructOrClass();
+ parseStructClassOrBracedList();
return;
case tok::semi:
nextToken();
} while (!eof());
}
-void UnwrappedLineParser::parseStructOrClass() {
+void UnwrappedLineParser::parseStructClassOrBracedList() {
nextToken();
do {
switch (FormatTok.Tok.getKind()) {
nextToken();
addUnwrappedLine();
return;
+ case tok::equal:
+ nextToken();
+ if (FormatTok.Tok.is(tok::l_brace)) {
+ parseBracedList();
+ }
+ break;
default:
nextToken();
break;
void parseNamespace();
void parseAccessSpecifier();
void parseEnum();
- void parseStructOrClass();
+ void parseStructClassOrBracedList();
void parseObjCProtocolList();
void parseObjCUntilAtEnd();
void parseObjCInterfaceOrImplementation();
"}");
}
+TEST_F(FormatTest, BracedInitListWithElaboratedTypeSpecifier) {
+ verifyFormat("struct foo a = { bar };\nint n;");
+}
+
// FIXME: This breaks the order of the unwrapped lines:
// TEST_F(FormatTest, OrderUnwrappedLines) {
// verifyFormat("{\n"