do not warn about -=/=- confusion with macros, thanks to rdogra for a testcase.

llvm-svn: 66416
This commit is contained in:
Chris Lattner 2009-03-09 07:11:10 +00:00
parent f183a3e95b
commit ed9f14c4c9
2 changed files with 6 additions and 1 deletions

View File

@ -3499,7 +3499,8 @@ QualType Sema::CheckAssignmentOperands(Expr *LHS, Expr *&RHS,
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()) {
Loc.getFileLocWithOffset(2) != UO->getSubExpr()->getLocStart() &&
UO->getSubExpr()->getLocStart().isFileID()) {
Diag(Loc, diag::warn_not_compound_assign)
<< (UO->getOpcode() == UnaryOperator::Plus ? "+" : "-")
<< SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());

View File

@ -25,6 +25,10 @@ void test4() {
var =+5; // no warning when the subexpr of the unary op has no space before it.
var =-5;
#define FIVE 5
var=-FIVE; // no warning with macros.
var=-FIVE;
}
// rdar://6319320