summaryrefslogtreecommitdiffstats
path: root/clang/test
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
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')
-rw-r--r--clang/test/CodeGenCXX/static-init-2.cpp2
-rw-r--r--clang/test/Sema/exprs.c5
-rw-r--r--clang/test/Sema/switch.c6
-rw-r--r--clang/test/SemaCXX/switch.cpp3
4 files changed, 8 insertions, 8 deletions
diff --git a/clang/test/CodeGenCXX/static-init-2.cpp b/clang/test/CodeGenCXX/static-init-2.cpp
index 7eb4a7d5aa7..65ab3bb1262 100644
--- a/clang/test/CodeGenCXX/static-init-2.cpp
+++ b/clang/test/CodeGenCXX/static-init-2.cpp
@@ -3,4 +3,4 @@
// Make sure we don't crash generating y; its value is constant, but the
// initializer has side effects, so EmitConstantExpr should fail.
int x();
-int y = x() && 0; // expected-warning {{use of logical && with constant operand}}
+int y = x() && 0;
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;
}
diff --git a/clang/test/Sema/switch.c b/clang/test/Sema/switch.c
index 4e39e0f0c2d..bb4822916cc 100644
--- a/clang/test/Sema/switch.c
+++ b/clang/test/Sema/switch.c
@@ -50,14 +50,12 @@ void test4()
}
switch (cond) {
- case g() && 0: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}} \
- expected-warning {{use of logical && with constant operand}}
+ case g() && 0: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}}
break;
}
switch (cond) {
- case 0 ... g() || 1: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}} \\
- expected-warning {{use of logical || with constant operand}}
+ case 0 ... g() || 1: // expected-error {{expression is not an integer constant expression}} // expected-note {{subexpression not valid in an integer constant expression}}
break;
}
}
diff --git a/clang/test/SemaCXX/switch.cpp b/clang/test/SemaCXX/switch.cpp
index 54240dcc305..fc13630bbf1 100644
--- a/clang/test/SemaCXX/switch.cpp
+++ b/clang/test/SemaCXX/switch.cpp
@@ -8,8 +8,7 @@ void test() {
}
int n = 3;
- switch (n && 1) { // expected-warning {{bool}} \
- // expected-warning {{use of logical && with constant operand}}
+ switch (n && 1) { // expected-warning {{bool}}
case 1:
break;
}
OpenPOWER on IntegriCloud