From d48fe24b55c66573c043a284fd28db34e6ccaf06 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Thu, 27 Feb 2014 02:43:25 +0000 Subject: [PATCH] As of r202325, CFGBlock predecessors may be NULL. Ignore such preds. Fixes a crasher, PR18983. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202340 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/AnalysisBasedWarnings.cpp | 1 + test/SemaCXX/switch-implicit-fallthrough.cpp | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/Sema/AnalysisBasedWarnings.cpp b/lib/Sema/AnalysisBasedWarnings.cpp index 099ef25373..e6f2f82dd2 100644 --- a/lib/Sema/AnalysisBasedWarnings.cpp +++ b/lib/Sema/AnalysisBasedWarnings.cpp @@ -887,6 +887,7 @@ namespace { while (!BlockQueue.empty()) { const CFGBlock *P = BlockQueue.front(); BlockQueue.pop_front(); + if (!P) continue; const Stmt *Term = P->getTerminator(); if (Term && isa(Term)) diff --git a/test/SemaCXX/switch-implicit-fallthrough.cpp b/test/SemaCXX/switch-implicit-fallthrough.cpp index d7959238c6..831324a64e 100644 --- a/test/SemaCXX/switch-implicit-fallthrough.cpp +++ b/test/SemaCXX/switch-implicit-fallthrough.cpp @@ -265,3 +265,16 @@ void fallthrough_in_local_class() { }; } +namespace PR18983 { + void fatal() __attribute__((noreturn)); + int num(); + void test() { + switch (num()) { + case 1: + fatal(); + // Don't issue a warning. + case 2: + break; + } + } +} -- 2.40.0