E.g.:
default:;
This can be used to get around restrictions as to what can follow a
label. It fixes llvm.org/PR19648.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236604
91177308-0d34-0410-b5e6-
96231b3b80d8
return false;
if (Right.is(tok::colon)) {
if (Line.First->isOneOf(tok::kw_case, tok::kw_default) ||
- !Right.getNextNonComment())
+ !Right.getNextNonComment() || Right.getNextNonComment()->is(tok::semi))
return false;
if (Right.is(TT_ObjCMethodExpr))
return false;
}
addUnwrappedLine();
} else {
+ if (FormatTok->is(tok::semi))
+ nextToken();
addUnwrappedLine();
}
Line->Level = OldLineLevel;
" case OP_name: \\\n"
" return operations::Operation##name\n",
getLLVMStyleWithColumns(40));
+ verifyFormat("switch (x) {\n"
+ "case 1:;\n"
+ "default:;\n"
+ " int i;\n"
+ "}");
verifyGoogleFormat("switch (x) {\n"
" case 1:\n"
"test_label:\n"
" some_other_code();\n"
"}");
+ verifyFormat("{\n"
+ " some_code();\n"
+ "test_label:;\n"
+ " int i = 0;\n"
+ "}");
}
//===----------------------------------------------------------------------===//