For -Wlogical-op-parentheses, point at '&&', not '||'. Fixes rdar://9125333.

llvm-svn: 130009
This commit is contained in:
Argyrios Kyrtzidis 2011-04-22 19:16:27 +00:00
parent 57c892860e
commit ad8b4d402e
2 changed files with 7 additions and 7 deletions

View File

@ -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());
}

View File

@ -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.