summaryrefslogtreecommitdiffstats
path: root/clang
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
commit1be4a59a110ba71682a70b352c36e80fb143929b (patch)
treede09feb59314216c2068d51d6e1b37e69b87d7ed /clang
parent5fcfb2fe0c1e0a82bb8d200b91826bf2325cbc3f (diff)
downloadbcm5719-llvm-1be4a59a110ba71682a70b352c36e80fb143929b.tar.gz
bcm5719-llvm-1be4a59a110ba71682a70b352c36e80fb143929b.zip
Teach -Wuninitialized about indirect goto. Fixes PR 9071.
llvm-svn: 124394
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Analysis/UninitializedValuesV2.cpp4
-rw-r--r--clang/test/Sema/uninit-variables.c11
2 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/Analysis/UninitializedValuesV2.cpp b/clang/lib/Analysis/UninitializedValuesV2.cpp
index b9a7676e62c..0867b5e7f3f 100644
--- a/clang/lib/Analysis/UninitializedValuesV2.cpp
+++ b/clang/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/clang/test/Sema/uninit-variables.c b/clang/test/Sema/uninit-variables.c
index 513298d9ac8..f52c1b5fc28 100644
--- a/clang/test/Sema/uninit-variables.c
+++ b/clang/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;
+}
+
OpenPOWER on IntegriCloud