summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/parentheses.c
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-11-17 18:26:36 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-11-17 18:26:36 +0000
commit14a96625b870c7a20dc1a9cea44a45d65e76863b (patch)
tree04d0a99a8438b77ad21095575626e3115edb2f1f /clang/test/Sema/parentheses.c
parentf10c43c7f791938c65005b0a605723bc9f240a74 (diff)
downloadbcm5719-llvm-14a96625b870c7a20dc1a9cea44a45d65e76863b.tar.gz
bcm5719-llvm-14a96625b870c7a20dc1a9cea44a45d65e76863b.zip
Don't warn for parentheses for the '&&' inside '||' for cases like:
assert(a || b && "bad"); since this is safe. This way we avoid a big source of such warnings which in this case are practically useless. Note that we don't handle *all* cases where precedence wouldn't matter because of constants since this is a bit costly to check, and IMO clarifying precedence with parentheses is good for readability in general. llvm-svn: 119533
Diffstat (limited to 'clang/test/Sema/parentheses.c')
-rw-r--r--clang/test/Sema/parentheses.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/test/Sema/parentheses.c b/clang/test/Sema/parentheses.c
index a219c9b342d..52aadde32e3 100644
--- a/clang/test/Sema/parentheses.c
+++ b/clang/test/Sema/parentheses.c
@@ -28,4 +28,10 @@ void bitwise_rel(unsigned i) {
(void)(i || i && i); // expected-warning {{'&&' within '||'}} \
// expected-note {{place parentheses around the '&&' expression to silence this warning}}
+ (void)(i || i && "w00t"); // no warning.
+ (void)("w00t" && i || i); // no warning.
+ (void)(i || i && "w00t" || i); // expected-warning {{'&&' within '||'}} \
+ // expected-note {{place parentheses around the '&&' expression to silence this warning}}
+ (void)(i || "w00t" && i || i); // expected-warning {{'&&' within '||'}} \
+ // expected-note {{place parentheses around the '&&' expression to silence this warning}}
}
OpenPOWER on IntegriCloud