]> granicus.if.org Git - clang/commitdiff
Fixed segmentation fault when a CFGBlock has NULL successor.
authorAlexander Kornienko <alexfh@google.com>
Fri, 1 Feb 2013 15:39:20 +0000 (15:39 +0000)
committerAlexander Kornienko <alexfh@google.com>
Fri, 1 Feb 2013 15:39:20 +0000 (15:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174182 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/AnalysisBasedWarnings.cpp
test/SemaCXX/switch-implicit-fallthrough.cpp

index b362239163371a9490822540e1728571bd065c75..5443edb191d1f709623c64ca0fe3c4f759cafcf6 100644 (file)
@@ -714,7 +714,7 @@ namespace {
         for (CFGBlock::const_succ_iterator I = P->succ_begin(),
                                            E = P->succ_end();
              I != E; ++I) {
-          if (ReachableBlocks.insert(*I))
+          if (*I && ReachableBlocks.insert(*I))
             BlockQueue.push_back(*I);
         }
       }
index 912b21ebfdb58d4b3ad368a30ad2f0f0a11d9e31..bc94c9e7507d05c238b6a6685edf5c7276727808 100644 (file)
@@ -172,6 +172,11 @@ int fallthrough_macro1(int n) {
   return n;
 }
 
+void fallthrough_cfgblock_with_null_successor(int x) {
+  (x && "") ? (void)(0) : (void)(1);
+  switch (x) {}
+}
+
 int fallthrough_position(int n) {
   switch (n) {
       [[clang::fallthrough]];  // expected-warning{{fallthrough annotation in unreachable code}}