From 07509dfa9efc989ea5d8cfc2e6d6c6332d583abd Mon Sep 17 00:00:00 2001 From: Stephan Bergmann <sbergman@redhat.com> Date: Fri, 24 Jun 2016 16:26:43 +0000 Subject: [PATCH] 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 --- lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp | 2 ++ test/Analysis/dead-stores.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp b/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp index f2a269a3335..8ca2a24cffe 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 da8e8bdb703..cddb6c666ad 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 +} -- GitLab