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)
llvm-svn: 174182

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

index b362239..5443edb 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 912b21e..bc94c9e 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}}