diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-03-08 06:51:10 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-03-08 06:51:10 +0000 |
| commit | 36c39c9b0a6a54a374f54bf693a2943f80dcd9c9 (patch) | |
| tree | eb7397f79f6987d3e3a4974f6d05f412969d681b /clang/lib | |
| parent | fbed86a865701c617425db187b757ab6b79aa588 (diff) | |
| download | bcm5719-llvm-36c39c9b0a6a54a374f54bf693a2943f80dcd9c9.tar.gz bcm5719-llvm-36c39c9b0a6a54a374f54bf693a2943f80dcd9c9.zip | |
refine the "use of unary operator that may be intended as compound assignment (+=)"
warning to only trigger when there is whitespace or something else after the + as
suggested by Eli.
llvm-svn: 66370
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 79be1625209..6c4176720af 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3479,10 +3479,14 @@ QualType Sema::CheckAssignmentOperands(Expr *LHS, Expr *&RHS, UO->getOpcode() == UnaryOperator::Minus) && Loc.isFileID() && UO->getOperatorLoc().isFileID() && // Only if the two operators are exactly adjacent. - Loc.getFileLocWithOffset(1) == UO->getOperatorLoc()) + Loc.getFileLocWithOffset(1) == UO->getOperatorLoc() && + // And there is a space or other character before the subexpr of the + // unary +/-. We don't want to warn on "x=-1". + Loc.getFileLocWithOffset(2) != UO->getSubExpr()->getLocStart()) { Diag(Loc, diag::warn_not_compound_assign) << (UO->getOpcode() == UnaryOperator::Plus ? "+" : "-") << SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc()); + } } } else { // Compound assignment "x += y" |

