[cfe-commits] r124394 - in /cfe/trunk: lib/Analysis/UninitializedValuesV2.cpp test/Sema/uninit-variables.c
Ted Kremenek
kremenek at apple.com
Thu Jan 27 10:51:39 PST 2011
Author: kremenek
Date: Thu Jan 27 12:51:39 2011
New Revision: 124394
URL: http://llvm.org/viewvc/llvm-project?rev=124394&view=rev
Log:
Teach -Wuninitialized about indirect goto. Fixes PR 9071.
Modified:
cfe/trunk/lib/Analysis/UninitializedValuesV2.cpp
cfe/trunk/test/Sema/uninit-variables.c
Modified: cfe/trunk/lib/Analysis/UninitializedValuesV2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/UninitializedValuesV2.cpp?rev=124394&r1=124393&r2=124394&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/UninitializedValuesV2.cpp (original)
+++ cfe/trunk/lib/Analysis/UninitializedValuesV2.cpp Thu Jan 27 12:51:39 2011
@@ -158,8 +158,8 @@
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);
Modified: cfe/trunk/test/Sema/uninit-variables.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/uninit-variables.c?rev=124394&r1=124393&r2=124394&view=diff
==============================================================================
--- cfe/trunk/test/Sema/uninit-variables.c (original)
+++ cfe/trunk/test/Sema/uninit-variables.c Thu Jan 27 12:51:39 2011
@@ -229,3 +229,14 @@
^{ 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;
+}
+
More information about the cfe-commits
mailing list