summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2016-06-24 16:26:43 +0000
committerStephan Bergmann <sbergman@redhat.com>2016-06-24 16:26:43 +0000
commit07509dfa9efc989ea5d8cfc2e6d6c6332d583abd (patch)
treeaafd7d4004bcaaedb275d96ec93ead5994b9699d
parente255c643e8bc7419282c20ee3736e6df879d5d29 (diff)
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
-rw-r--r--lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp2
-rw-r--r--test/Analysis/dead-stores.c4
2 files changed, 6 insertions, 0 deletions
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
+}