Just bail out immediately when emitting an unreachable function-local static

variable.  Surprisingly, this does seem to be the right way to solve this.

llvm-svn: 102961
This commit is contained in:
John McCall 2010-05-03 21:39:56 +00:00
parent c936b56871
commit 5828ee7a27
2 changed files with 14 additions and 0 deletions

View File

@ -231,6 +231,9 @@ CodeGenFunction::AddInitializerToGlobalBlockVarDecl(const VarDecl &D,
void CodeGenFunction::EmitStaticBlockVarDecl(const VarDecl &D,
llvm::GlobalValue::LinkageTypes Linkage) {
// Bail out early if the block is unreachable.
if (!Builder.GetInsertBlock()) return;
llvm::Value *&DMEntry = LocalDeclMap[&D];
assert(DMEntry == 0 && "Decl already exists in localdeclmap!");

View File

@ -34,3 +34,14 @@ inline void h2() {
void h3() {
h2();
}
// PR6980: this shouldn't crash
namespace test0 {
struct A { A(); };
__attribute__((noreturn)) int throw_exception();
void test() {
throw_exception();
static A r;
}
}