diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-09 07:11:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-09 07:11:10 +0000 |
commit | 3e87209798bcc3fe39254c1b700b0c8251623b98 (patch) | |
tree | 7dd5bc52a509fadba467fa31f6de535ad64f116e | |
parent | a7dbdf5c76d5da124f9384012c89eb1602de58e2 (diff) |
do not warn about -=/=- confusion with macros, thanks to rdogra for a testcase.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66416 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaExpr.cpp | 3 | ||||
-rw-r--r-- | test/Sema/exprs.c | 4 |
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 4fb03b3d6b..4ba35a593c 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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()); diff --git a/test/Sema/exprs.c b/test/Sema/exprs.c index 25da12b586..8bf42f7d7d 100644 --- a/test/Sema/exprs.c +++ b/test/Sema/exprs.c @@ -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 |