summaryrefslogtreecommitdiff
path: root/test/SemaCXX
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2017-11-17 21:33:28 +0000
committerReid Kleckner <rnk@google.com>2017-11-17 21:33:28 +0000
commit2609dad5c858f00be635e088a945ed1cd680fcd4 (patch)
tree24049c422ffc931d0d05057ec097d764cd395d25 /test/SemaCXX
parent656eb5d6f080498602779be5ce01eb9a79ad2d05 (diff)
Loosen -Wempty-body warning
Do not show it when `if` or `else` come from macros. E.g., #define USED(A) if (A); else #define SOME_IF(A) if (A) void test() { // No warnings are shown in those cases now. USED(0); SOME_IF(0); } Patch by Ilya Biryukov! Differential Revision: https://reviews.llvm.org/D40185 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@318556 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/SemaCXX')
-rw-r--r--test/SemaCXX/warn-empty-body.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/test/SemaCXX/warn-empty-body.cpp b/test/SemaCXX/warn-empty-body.cpp
index bd6b47f053..0fc0cd51f9 100644
--- a/test/SemaCXX/warn-empty-body.cpp
+++ b/test/SemaCXX/warn-empty-body.cpp
@@ -301,3 +301,14 @@ void test7(int x, int y) {
if (x) IDENTITY(); // no-warning
}
+#define SOME_IF(A) if (A)
+#define IF_ELSE(A) if (A); else
+
+
+void test_macros() {
+ SOME_IF(0);
+ IF_ELSE(0);
+
+ IDENTITY(if (0);) // expected-warning{{if statement has empty body}} expected-note{{separate line}}
+ IDENTITY(if (0); else;) // expected-warning{{else clause has empty body}} expected-note{{separate line}}}
+}