From: Alexander Kornienko Date: Fri, 1 Feb 2013 15:39:20 +0000 (+0000) Subject: Fixed segmentation fault when a CFGBlock has NULL successor. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0162b832fd6450cd3a23019a3c900382d0e9415c;p=clang Fixed segmentation fault when a CFGBlock has NULL successor. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174182 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index b362239163..5443edb191 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/lib/Sema/AnalysisBasedWarnings.cpp @@ -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); } } diff --git a/test/SemaCXX/switch-implicit-fallthrough.cpp b/test/SemaCXX/switch-implicit-fallthrough.cpp index 912b21ebfd..bc94c9e750 100644 --- a/test/SemaCXX/switch-implicit-fallthrough.cpp +++ b/test/SemaCXX/switch-implicit-fallthrough.cpp @@ -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}}