[cfe-commits] r66416 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/exprs.c
Chris Lattner
sabre at nondot.org
Mon Mar 9 00:11:11 PDT 2009
Author: lattner
Date: Mon Mar 9 02:11:10 2009
New Revision: 66416
URL: http://llvm.org/viewvc/llvm-project?rev=66416&view=rev
Log:
do not warn about -=/=- confusion with macros, thanks to rdogra for a testcase.
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/exprs.c
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=66416&r1=66415&r2=66416&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Mar 9 02:11:10 2009
@@ -3499,7 +3499,8 @@
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());
Modified: cfe/trunk/test/Sema/exprs.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/exprs.c?rev=66416&r1=66415&r2=66416&view=diff
==============================================================================
--- cfe/trunk/test/Sema/exprs.c (original)
+++ cfe/trunk/test/Sema/exprs.c Mon Mar 9 02:11:10 2009
@@ -25,6 +25,10 @@
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
More information about the cfe-commits
mailing list