diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-04-22 19:16:27 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-04-22 19:16:27 +0000 |
commit | ad8b4d402e8a1edb2475098c0289784d7bd2d348 (patch) | |
tree | 12b9214decf3cb6704b11e5055bd7f1338799f95 | |
parent | 57c892860efee1d10f9b134951d61387ef3ff9ca (diff) | |
download | bcm5719-llvm-ad8b4d402e8a1edb2475098c0289784d7bd2d348.tar.gz bcm5719-llvm-ad8b4d402e8a1edb2475098c0289784d7bd2d348.zip |
For -Wlogical-op-parentheses, point at '&&', not '||'. Fixes rdar://9125333.
llvm-svn: 130009
-rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 11 | ||||
-rw-r--r-- | clang/test/Sema/parentheses.c | 3 |
2 files changed, 7 insertions, 7 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 0e0bf435b27..a773c3a8173 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -8788,14 +8788,13 @@ static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc, /// in parentheses. static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc, - Expr *E) { - assert(isa<BinaryOperator>(E) && - cast<BinaryOperator>(E)->getOpcode() == BO_LAnd); - SuggestParentheses(Self, OpLoc, + BinaryOperator *Bop) { + assert(Bop->getOpcode() == BO_LAnd); + SuggestParentheses(Self, Bop->getOperatorLoc(), Self.PDiag(diag::warn_logical_and_in_logical_or) - << E->getSourceRange(), + << Bop->getSourceRange() << OpLoc, Self.PDiag(diag::note_logical_and_in_logical_or_silence), - E->getSourceRange(), + Bop->getSourceRange(), Self.PDiag(0), SourceRange()); } diff --git a/clang/test/Sema/parentheses.c b/clang/test/Sema/parentheses.c index b45d8512f6b..a25ded66a66 100644 --- a/clang/test/Sema/parentheses.c +++ b/clang/test/Sema/parentheses.c @@ -26,7 +26,8 @@ void bitwise_rel(unsigned i) { (void)(i == 1 | i == 2 | i == 3); (void)(i != 1 & i != 2 & i != 3); - (void)(i || i && i); // expected-warning {{'&&' within '||'}} \ + (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. |