[cfe-commits] r130009 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/parentheses.c
Argyrios Kyrtzidis
akyrtzi at gmail.com
Fri Apr 22 12:16:27 PDT 2011
Author: akirtzidis
Date: Fri Apr 22 14:16:27 2011
New Revision: 130009
URL: http://llvm.org/viewvc/llvm-project?rev=130009&view=rev
Log:
For -Wlogical-op-parentheses, point at '&&', not '||'. Fixes rdar://9125333.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/parentheses.c
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=130009&r1=130008&r2=130009&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Apr 22 14:16:27 2011
@@ -8788,14 +8788,13 @@
/// 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());
}
Modified: cfe/trunk/test/Sema/parentheses.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/parentheses.c?rev=130009&r1=130008&r2=130009&view=diff
==============================================================================
--- cfe/trunk/test/Sema/parentheses.c (original)
+++ cfe/trunk/test/Sema/parentheses.c Fri Apr 22 14:16:27 2011
@@ -26,7 +26,8 @@
(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.
More information about the cfe-commits
mailing list