From: Stephan Bergmann Date: Fri, 24 Jun 2016 16:26:43 +0000 (+0000) Subject: DeadStoresChecker: Don't warn about dead stores into volatile variables X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=07509dfa9efc989ea5d8cfc2e6d6c6332d583abd;p=clang DeadStoresChecker: Don't warn about dead stores into volatile variables git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273689 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp b/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp index f2a269a333..8ca2a24cff 100644 --- a/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp +++ b/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp @@ -278,6 +278,8 @@ public: RHS = RHS->IgnoreParenCasts(); QualType T = VD->getType(); + if (T.isVolatileQualified()) + return; if (T->isPointerType() || T->isObjCObjectPointerType()) { if (RHS->isNullPointerConstant(Ctx, Expr::NPC_ValueDependentIsNull)) return; diff --git a/test/Analysis/dead-stores.c b/test/Analysis/dead-stores.c index da8e8bdb70..cddb6c666a 100644 --- a/test/Analysis/dead-stores.c +++ b/test/Analysis/dead-stores.c @@ -569,3 +569,7 @@ void testBOComma() { } +void testVolatile() { + volatile int v; + v = 0; // no warning +}