]> granicus.if.org Git - clang/commitdiff
Issue dead store warnings for preincrements involved in a subexpression.
authorTed Kremenek <kremenek@apple.com>
Thu, 24 Jul 2008 17:01:17 +0000 (17:01 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 24 Jul 2008 17:01:17 +0000 (17:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53983 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/CheckDeadStores.cpp
test/Analysis/dead-stores.c

index 433e61154f9c7d9d40d0fe47302480f1dc569932..4ab6680a78d29afc2bce4c4b854c42dd6e3ee9e5 100644 (file)
@@ -152,12 +152,7 @@ public:
     else if (UnaryOperator* U = dyn_cast<UnaryOperator>(S)) {
       if (!U->isIncrementOp())
         return;
-      
-      // Don't flag dead stores when the result of a preincrement/predecrement
-      // is used in an enclosing expression.
-      if (U->isPrefix() && Parents.isSubExpr(U))
-        return;
-      
+
       Expr *Ex = U->getSubExpr()->IgnoreParenCasts();
       
       if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(Ex))
index 381bfcb2cf21ac9fa468dccf988a09d20c216688..dce058c02e4bc65c74f8ede25ddb669dd04f050f 100644 (file)
@@ -74,7 +74,7 @@ int f10() {
 
 int f11() {
   int x = 4;
-  return ++x; // no-warning
+  return ++x; // expected-warning{{never read}}
 }