diff options
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 2 | ||||
-rw-r--r-- | test/CodeGenCXX/PR5863-unreachable-block.cpp | 13 |
2 files changed, 14 insertions, 1 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 589273da43..3e807bdbc7 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -80,7 +80,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S) { // explicitly here. This handles the common case of a call to a noreturn // function. if (llvm::BasicBlock *CurBB = Builder.GetInsertBlock()) { - if (CurBB->empty() && CurBB->use_empty()) { + if (CurBB->empty() && CurBB->use_empty() && !BlockScopes.count(CurBB)) { CurBB->eraseFromParent(); Builder.ClearInsertionPoint(); } diff --git a/test/CodeGenCXX/PR5863-unreachable-block.cpp b/test/CodeGenCXX/PR5863-unreachable-block.cpp new file mode 100644 index 0000000000..91221c9a7a --- /dev/null +++ b/test/CodeGenCXX/PR5863-unreachable-block.cpp @@ -0,0 +1,13 @@ +// RUN: %clang_cc1 -emit-llvm-only %s + +// PR5836 +class E { }; + +void P1() { + try { + int a=0, b=0; + if (a > b) // simply filling in 0 or 1 doesn't trigger the assertion + throw E(); // commenting out 'if' or 'throw' 'fixes' the assertion failure + try { } catch (...) { } // empty try/catch block needed for failure + } catch (...) { } // this try/catch block needed for failure +} |