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 b362239..5443edb 100644
--- a/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/lib/Sema/AnalysisBasedWarnings.cpp
@@ -714,7 +714,7 @@
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 912b21e..bc94c9e 100644
--- a/test/SemaCXX/switch-implicit-fallthrough.cpp
+++ b/test/SemaCXX/switch-implicit-fallthrough.cpp
@@ -172,6 +172,11 @@
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}}