summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2007-10-10 20:50:11 +0000
committerAnders Carlsson <andersca@mac.com>2007-10-10 20:50:11 +0000
commitdb83d77c78772b0188495093186b88b4ad2ea857 (patch)
tree11dcc7eb63e157343e45ca1749aa4e7d4db94f30 /clang/test
parent4479f86c0fa9853520f63d10d8e47c389dc32be9 (diff)
downloadbcm5719-llvm-db83d77c78772b0188495093186b88b4ad2ea857.tar.gz
bcm5719-llvm-db83d77c78772b0188495093186b88b4ad2ea857.zip
Emit a warning when the body of an if block is a NullStmt.
llvm-svn: 42840
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Parser/pointer_promotion.c12
-rw-r--r--clang/test/Sema/default.c2
-rw-r--r--clang/test/Sema/if-empty-body.c9
3 files changed, 16 insertions, 7 deletions
diff --git a/clang/test/Parser/pointer_promotion.c b/clang/test/Parser/pointer_promotion.c
index 9d9a5265676..8d2e6e7a80c 100644
--- a/clang/test/Parser/pointer_promotion.c
+++ b/clang/test/Parser/pointer_promotion.c
@@ -8,11 +8,11 @@ int test() {
struct bar *bp;
short sint = 7;
- if (ip < cp) ; // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
- if (cp < fp) ; // expected-warning {{comparison of distinct pointer types ('char *' and 'struct foo *')}}
- if (fp < bp) ; // expected-warning {{comparison of distinct pointer types ('struct foo *' and 'struct bar *')}}
- if (ip < 7) ; // expected-warning {{comparison between pointer and integer ('int *' and 'int')}}
- if (sint < ip) ; // expected-warning {{comparison between pointer and integer ('int' and 'int *')}}
- if (ip == cp) ; // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
+ if (ip < cp) {} // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
+ if (cp < fp) {} // expected-warning {{comparison of distinct pointer types ('char *' and 'struct foo *')}}
+ if (fp < bp) {} // expected-warning {{comparison of distinct pointer types ('struct foo *' and 'struct bar *')}}
+ if (ip < 7) {} // expected-warning {{comparison between pointer and integer ('int *' and 'int')}}
+ if (sint < ip) {} // expected-warning {{comparison between pointer and integer ('int' and 'int *')}}
+ if (ip == cp) {} // expected-warning {{comparison of distinct pointer types ('int *' and 'char *')}}
}
diff --git a/clang/test/Sema/default.c b/clang/test/Sema/default.c
index b51ab9a55cc..92f7278033f 100644
--- a/clang/test/Sema/default.c
+++ b/clang/test/Sema/default.c
@@ -3,6 +3,6 @@
void f5 (int z) {
if (z)
default: // expected-error {{not in switch statement}}
- ;
+ ; // expected-warning {{if statement has empty body}}
}
diff --git a/clang/test/Sema/if-empty-body.c b/clang/test/Sema/if-empty-body.c
new file mode 100644
index 00000000000..1dc9e448177
--- /dev/null
+++ b/clang/test/Sema/if-empty-body.c
@@ -0,0 +1,9 @@
+// RUN: clang -parse-ast -verify %s
+
+void f1(int a) {
+ if (a); // expected-warning {{if statement has empty body}}
+}
+
+void f2(int a) {
+ if (a) {}
+}
OpenPOWER on IntegriCloud