summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-03-09 07:11:10 +0000
committerChris Lattner <sabre@nondot.org>2009-03-09 07:11:10 +0000
commited9f14c4c9f3ebc13c1c858b6e26a9cd7f30d6d6 (patch)
tree776a696a9f3ec3bdb7b13fe2a6958882d2cfc335 /clang
parentf183a3e95bfe83a2d47e153ad6d3a3d92ee0049e (diff)
downloadbcm5719-llvm-ed9f14c4c9f3ebc13c1c858b6e26a9cd7f30d6d6.tar.gz
bcm5719-llvm-ed9f14c4c9f3ebc13c1c858b6e26a9cd7f30d6d6.zip
do not warn about -=/=- confusion with macros, thanks to rdogra for a testcase.
llvm-svn: 66416
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Sema/SemaExpr.cpp3
-rw-r--r--clang/test/Sema/exprs.c4
2 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 4fb03b3d6bc..4ba35a593c2 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/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/clang/test/Sema/exprs.c b/clang/test/Sema/exprs.c
index 25da12b5861..8bf42f7d7dd 100644
--- a/clang/test/Sema/exprs.c
+++ b/clang/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
OpenPOWER on IntegriCloud