summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaCXX/if-empty-body.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-11-19 20:54:25 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-11-19 20:54:25 +0000
commit90ee2a4ecf8ef519ebce5e8fc388d6f818ab1019 (patch)
tree52d750b9607a311ae1a14cea8d1a4b7bdfb60985 /clang/test/SemaCXX/if-empty-body.cpp
parentefed613172d902cf2ce49f68dd36f15a29a34dab (diff)
downloadbcm5719-llvm-90ee2a4ecf8ef519ebce5e8fc388d6f818ab1019.tar.gz
bcm5719-llvm-90ee2a4ecf8ef519ebce5e8fc388d6f818ab1019.zip
Don't warn for empty 'if' body if there is a macro that expands to nothing, e.g:
if (condition) CALL(0); // empty macro but don't warn for empty body. Fixes rdar://8436021. llvm-svn: 119838
Diffstat (limited to 'clang/test/SemaCXX/if-empty-body.cpp')
-rw-r--r--clang/test/SemaCXX/if-empty-body.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/if-empty-body.cpp b/clang/test/SemaCXX/if-empty-body.cpp
new file mode 100644
index 00000000000..ec7f89d68e7
--- /dev/null
+++ b/clang/test/SemaCXX/if-empty-body.cpp
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void f1(int a) {
+ if (a); // expected-warning {{if statement has empty body}}
+}
+
+void f2(int a) {
+ if (a) {}
+}
+
+void f3() {
+ if (1)
+ xx; // expected-error {{use of undeclared identifier}}
+ return; // no empty body warning.
+}
+
+// Don't warn about an empty body if is expanded from a macro.
+void f4(int i) {
+ #define BODY(x)
+ if (i == i) // expected-warning{{self-comparison always evaluates to true}}
+ BODY(0);
+ #undef BODY
+}
+
+template <typename T>
+void tf() {
+ #define BODY(x)
+ if (0)
+ BODY(0);
+ #undef BODY
+}
+
+void f5() {
+ tf<int>();
+}
OpenPOWER on IntegriCloud