From 2b800b8732778d7a72a49e78d08233e2215fcfdc Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sun, 20 Oct 2013 02:07:36 +0200 Subject: [PATCH] Fix catch clause codegen. In the 2.064 frontend, the catch variables have a zero initializer, so DtoDeclarationExp overwrote the actually caught exception with null. --- ir/irlandingpad.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/ir/irlandingpad.cpp b/ir/irlandingpad.cpp index f2d254c1..b25da28e 100644 --- a/ir/irlandingpad.cpp +++ b/ir/irlandingpad.cpp @@ -60,13 +60,11 @@ void IRLandingPadCatchInfo::toIR() catchStmt->var->ir.irLocal = new IrLocal(catchStmt->var); LLValue* catch_var = gIR->func()->gen->landingPadInfo.getExceptionStorage(); catchStmt->var->ir.irLocal->value = gIR->ir->CreateBitCast(catch_var, getPtrToType(DtoType(catchStmt->var->type))); - } + } else { + // this will alloca if we haven't already and take care of nested refs + DtoDeclarationExp(catchStmt->var); - // this will alloca if we haven't already and take care of nested refs - DtoDeclarationExp(catchStmt->var); - - // the exception will only be stored in catch_var. copy it over if necessary - if (catchStmt->var->ir.irLocal->value != gIR->func()->gen->landingPadInfo.getExceptionStorage()) { + // the exception will only be stored in catch_var. copy it over if necessary LLValue* exc = gIR->ir->CreateBitCast(DtoLoad(gIR->func()->gen->landingPadInfo.getExceptionStorage()), DtoType(catchStmt->var->type)); DtoStore(exc, catchStmt->var->ir.irLocal->value); }