diff options
author | Reid Kleckner <rnk@google.com> | 2017-11-16 21:26:18 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2017-11-16 21:26:18 +0000 |
commit | adefb760a835a6bc0f6eef4d77d1f50b5082f147 (patch) | |
tree | e5ccfc57092d305d4d39dc934417dbdf1ea82cde /clang/test/SemaCXX/warn-empty-body.cpp | |
parent | 53418797fd7dc3286ca360d99d44a7baed0d6069 (diff) | |
download | bcm5719-llvm-adefb760a835a6bc0f6eef4d77d1f50b5082f147.tar.gz bcm5719-llvm-adefb760a835a6bc0f6eef4d77d1f50b5082f147.zip |
Issue -Wempty-body warnings for else blocks
This looks like it was just an oversight.
Fixes http://llvm.org/pr35319
llvm-svn: 318456
Diffstat (limited to 'clang/test/SemaCXX/warn-empty-body.cpp')
-rw-r--r-- | clang/test/SemaCXX/warn-empty-body.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/warn-empty-body.cpp b/clang/test/SemaCXX/warn-empty-body.cpp index a248c4251d5..bd6b47f053f 100644 --- a/clang/test/SemaCXX/warn-empty-body.cpp +++ b/clang/test/SemaCXX/warn-empty-body.cpp @@ -238,6 +238,26 @@ void test6(int x, int y) { } } +void test_if_else(int x) { + if (x); // expected-warning{{if statement has empty body}} expected-note{{separate line}} + + if (x) + ; // no-warning + + if (x) + ; // no-warning + else + ; // no-warning + + if (x) + ; // no-warning + else; // expected-warning{{else clause has empty body}} expected-note{{separate line}} + + if (x) + ; // no-warning + else EMPTY(x); // no-warning +} + void test_errors(int x) { if (1) aa; // expected-error{{use of undeclared identifier}} |