]> granicus.if.org Git - clang/commitdiff
Teach -Wuninitialized about indirect goto. Fixes PR 9071.
authorTed Kremenek <kremenek@apple.com>
Thu, 27 Jan 2011 18:51:39 +0000 (18:51 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 27 Jan 2011 18:51:39 +0000 (18:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124394 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/UninitializedValuesV2.cpp
test/Sema/uninit-variables.c

index b9a7676e62cdae05bdb7e0052f2553054cbb5934..0867b5e7f3f262f5b3f641851b222bbfa5fa1833 100644 (file)
@@ -158,8 +158,8 @@ static BinaryOperator *getLogicalOperatorInChain(const CFGBlock *block) {
 llvm::BitVector &CFGBlockValues::getBitVector(const CFGBlock *block,
                                               const CFGBlock *dstBlock) {
   unsigned idx = block->getBlockID();
-  if (dstBlock && block->succ_size() == 2 && block->pred_size() == 2) {
-    assert(block->getTerminator());
+  if (dstBlock && block->succ_size() == 2 && block->pred_size() == 2 &&
+      block->getTerminator()) {
     if (getLogicalOperatorInChain(block)) {
       if (*block->succ_begin() == dstBlock)
         return lazyCreate(vals[idx].first);
index 513298d9ac8bf03ea08823e87b86a08abc384a72..f52c1b5fc28c976ef5181a41cb3f17173fb5b744 100644 (file)
@@ -229,3 +229,14 @@ void test35(int x) {
   ^{ y = (x == 0); }();
 }
 
+// Test handling of indirect goto.
+void test36()
+{
+  void **pc; // expected-warning{{use of uninitialized variable 'pc'}} expected-note{{ add initialization to silence this warning}}
+  void *dummy[] = { &&L1, &&L2 };
+ L1:
+    goto *pc; // expected-note{{variable 'pc' is possibly uninitialized when used here}}
+ L2:
+    goto *pc;
+}
+