summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/exprs.c
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-07-24 01:10:11 +0000
committerChris Lattner <sabre@nondot.org>2010-07-24 01:10:11 +0000
commit938533db602b32ab435078e723b656ac6e779a1b (patch)
tree28fcb33de3164d91686eab700b56444ac612833f /clang/test/Sema/exprs.c
parent268ad093a7ae4633fec3b2525a1c7d66715e0553 (diff)
downloadbcm5719-llvm-938533db602b32ab435078e723b656ac6e779a1b.tar.gz
bcm5719-llvm-938533db602b32ab435078e723b656ac6e779a1b.zip
turn down the logical bitwise confusion warning to not warn
when the RHS of the ||/&& is ever 0 or 1. This handles a variety of creative idioms for "true" used in C programs and fixes many false positives at the expense of a few false negatives. This fixes rdar://8230351. llvm-svn: 109314
Diffstat (limited to 'clang/test/Sema/exprs.c')
-rw-r--r--clang/test/Sema/exprs.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c
index 9d3da908549..56a52bed1bc 100644
--- a/clang/test/Sema/exprs.c
+++ b/clang/test/Sema/exprs.c
@@ -145,5 +145,8 @@ void test19() {
int test20(int x) {
return x && 4; // expected-warning {{use of logical && with constant operand; switch to bitwise & or remove constant}}
- return x && sizeof(int) == 4; // no warning.
+ return x && sizeof(int) == 4; // no warning, RHS is logical op.
+
+ // no warning, this is an idiom for "true" in old C style.
+ return x && (signed char)1;
}
OpenPOWER on IntegriCloud