aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-01-27 18:51:39 +0000
committerTed Kremenek <kremenek@apple.com>2011-01-27 18:51:39 +0000
commit96554fd1aa7350498de8911fb6f303a9262e6ec0 (patch)
tree66e815b5d4c379bf15b0029a53bc6e52af675e65
parent8c29cfa09fa46387e90ecd74f4f5c447eab1c38f (diff)
Teach -Wuninitialized about indirect goto. Fixes PR 9071.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124394 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/UninitializedValuesV2.cpp4
-rw-r--r--test/Sema/uninit-variables.c11
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/Analysis/UninitializedValuesV2.cpp b/lib/Analysis/UninitializedValuesV2.cpp
index b9a7676e62..0867b5e7f3 100644
--- a/lib/Analysis/UninitializedValuesV2.cpp
+++ b/lib/Analysis/UninitializedValuesV2.cpp
@@ -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);
diff --git a/test/Sema/uninit-variables.c b/test/Sema/uninit-variables.c
index 513298d9ac..f52c1b5fc2 100644
--- a/test/Sema/uninit-variables.c
+++ b/test/Sema/uninit-variables.c
@@ -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;
+}
+