diff options
| author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-17 18:26:36 +0000 |
|---|---|---|
| committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-17 18:26:36 +0000 |
| commit | 14a96625b870c7a20dc1a9cea44a45d65e76863b (patch) | |
| tree | 04d0a99a8438b77ad21095575626e3115edb2f1f /clang/test/Sema/parentheses.c | |
| parent | f10c43c7f791938c65005b0a605723bc9f240a74 (diff) | |
| download | bcm5719-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.c | 6 |
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}} } |

