]> granicus.if.org Git - clang/commitdiff
DeadStoresChecker: Don't warn about dead stores into volatile variables
authorStephan Bergmann <sbergman@redhat.com>
Fri, 24 Jun 2016 16:26:43 +0000 (16:26 +0000)
committerStephan Bergmann <sbergman@redhat.com>
Fri, 24 Jun 2016 16:26:43 +0000 (16:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273689 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
test/Analysis/dead-stores.c

index f2a269a3335c50aa6d8fdff6fdd1b7c4eb347b8a..8ca2a24cffe74b1fd268a25bc6e7cd606233650c 100644 (file)
@@ -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;
index da8e8bdb70344529c0cfae27a9522a6c4c23faf4..cddb6c666ad5b5c5a92bfdef3f975dca608eefd2 100644 (file)
@@ -569,3 +569,7 @@ void testBOComma() {
 
 }
 
+void testVolatile() {
+    volatile int v;
+    v = 0; // no warning
+}