[cfe-commits] r94086 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/Sema/warn-unreachable.c
Mike Stump
mrs at apple.com
Thu Jan 21 09:31:41 PST 2010
Author: mrs
Date: Thu Jan 21 11:31:41 2010
New Revision: 94086
URL: http://llvm.org/viewvc/llvm-project?rev=94086&view=rev
Log:
Improve unreachable code warnings for with respect to compound
assignments.
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/warn-unreachable.c
Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=94086&r1=94085&r2=94086&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Jan 21 11:31:41 2010
@@ -2102,6 +2102,12 @@
R1 = UO->getSubExpr()->getSourceRange();
return UO->getOperatorLoc();
}
+ case Expr::CompoundAssignOperatorClass: {
+ const CompoundAssignOperator *CAO = cast<CompoundAssignOperator>(S);
+ R1 = CAO->getLHS()->getSourceRange();
+ R2 = CAO->getRHS()->getSourceRange();
+ return CAO->getOperatorLoc();
+ }
case Stmt::CXXTryStmtClass: {
return cast<CXXTryStmt>(S)->getHandler(0)->getCatchLoc();
}
Modified: cfe/trunk/test/Sema/warn-unreachable.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-unreachable.c?rev=94086&r1=94085&r2=94086&view=diff
==============================================================================
--- cfe/trunk/test/Sema/warn-unreachable.c (original)
+++ cfe/trunk/test/Sema/warn-unreachable.c Thu Jan 21 11:31:41 2010
@@ -24,6 +24,7 @@
}
void test2() {
+ int i;
switch (live()) {
case 1:
halt(),
@@ -78,5 +79,9 @@
dead();
- // expected-warning {{will never be executed}}
halt();
+ case 8:
+ i
+ += // expected-warning {{will never be executed}}
+ halt();
}
}
More information about the cfe-commits
mailing list