From: Ted Kremenek Date: Thu, 24 Jul 2008 17:01:17 +0000 (+0000) Subject: Issue dead store warnings for preincrements involved in a subexpression. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0f36323d9d8392075274b95816e2241f99ddb0d;p=clang Issue dead store warnings for preincrements involved in a subexpression. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@53983 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Analysis/CheckDeadStores.cpp b/lib/Analysis/CheckDeadStores.cpp index 433e61154f..4ab6680a78 100644 --- a/lib/Analysis/CheckDeadStores.cpp +++ b/lib/Analysis/CheckDeadStores.cpp @@ -152,12 +152,7 @@ public: else if (UnaryOperator* U = dyn_cast(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(Ex)) diff --git a/test/Analysis/dead-stores.c b/test/Analysis/dead-stores.c index 381bfcb2cf..dce058c02e 100644 --- a/test/Analysis/dead-stores.c +++ b/test/Analysis/dead-stores.c @@ -74,7 +74,7 @@ int f10() { int f11() { int x = 4; - return ++x; // no-warning + return ++x; // expected-warning{{never read}} }