summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/warn-unreachable.c
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2012-08-24 07:42:09 +0000
committerTed Kremenek <kremenek@apple.com>2012-08-24 07:42:09 +0000
commit64fea5fc8fa0e2f75fc1a3edcabeb87b001566a1 (patch)
tree25810dfd21eaf3642de0823128d3b8b3f984c721 /clang/test/Sema/warn-unreachable.c
parent75c100b8e5d4a464521c9ad0f9a74e4f42b314d3 (diff)
downloadbcm5719-llvm-64fea5fc8fa0e2f75fc1a3edcabeb87b001566a1.tar.gz
bcm5719-llvm-64fea5fc8fa0e2f75fc1a3edcabeb87b001566a1.zip
Teach CFG that 'if (x & 0)' and 'if (x * 0)' is an unfeasible branch.
Fixes <rdar://problem/11005770>. llvm-svn: 162545
Diffstat (limited to 'clang/test/Sema/warn-unreachable.c')
-rw-r--r--clang/test/Sema/warn-unreachable.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/test/Sema/warn-unreachable.c b/clang/test/Sema/warn-unreachable.c
index 636513f62c7..2fbe1c78eb2 100644
--- a/clang/test/Sema/warn-unreachable.c
+++ b/clang/test/Sema/warn-unreachable.c
@@ -132,3 +132,12 @@ void PR9774(int *s) {
s[i] = 0;
}
+// Test case for <rdar://problem/11005770>. We should treat code guarded
+// by 'x & 0' and 'x * 0' as unreachable.
+void calledFun();
+void test_mul_and_zero(int x) {
+ if (x & 0) calledFun(); // expected-warning {{will never be executed}}
+ if (0 & x) calledFun(); // expected-warning {{will never be executed}}
+ if (x * 0) calledFun(); // expected-warning {{will never be executed}}
+ if (0 * x) calledFun(); // expected-warning {{will never be executed}}
+}
OpenPOWER on IntegriCloud