summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-04-07 14:36:33 +0000
committerDaniel Jasper <djasper@google.com>2015-04-07 14:36:33 +0000
commit676e516354c38ebb496c41cfa6560336de3f0535 (patch)
tree37202d5ee1624f41d24e130e2144b2ba085d9c16 /clang/unittests/Format/FormatTest.cpp
parent67239b2f730bef55385098ba9622fb5ef1195ee2 (diff)
downloadbcm5719-llvm-676e516354c38ebb496c41cfa6560336de3f0535.tar.gz
bcm5719-llvm-676e516354c38ebb496c41cfa6560336de3f0535.zip
clang-format: Don't allow labels when expecting declarations.
This fixes formatting unnamed bitfields (llvm.org/PR21999). Before: struct MyStruct { uchar data; uchar: 8; uchar: 8; uchar other; }; After: struct MyStruct { uchar data; uchar : 8; uchar : 8; uchar other; }; llvm-svn: 234318
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 183fa4418be..16062dd40b7 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -812,9 +812,11 @@ TEST_F(FormatTest, FormatsLabels) {
" some_more_code();\n"
" }\n"
"}");
- verifyFormat("some_code();\n"
+ verifyFormat("{\n"
+ " some_code();\n"
"test_label:\n"
- "some_other_code();");
+ " some_other_code();\n"
+ "}");
}
//===----------------------------------------------------------------------===//
@@ -2143,6 +2145,12 @@ TEST_F(FormatTest, FormatsBitfields) {
" int aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa : 1,\n"
" bbbbbbbbbbbbbbbbbbbbbbbbb;\n"
"};");
+ verifyFormat("struct MyStruct {\n"
+ " uchar data;\n"
+ " uchar : 8;\n"
+ " uchar : 8;\n"
+ " uchar other;\n"
+ "};");
}
TEST_F(FormatTest, FormatsNamespaces) {
OpenPOWER on IntegriCloud