diff --git a/gcc/d/ChangeLog b/gcc/d/ChangeLog index f551debf1..73090195e 100644 --- a/gcc/d/ChangeLog +++ b/gcc/d/ChangeLog @@ -1,3 +1,8 @@ +2015-08-22 Iain Buclaw + + * toir.cc(IRVisitor::visit(TryCatchStatement)): Always emit call to + LIBCALL_BEGIN_CATCH at the start of the catch. + 2015-08-20 Iain Buclaw * toir.cc(IRVisitor::visit): Set input location in all visitors that diff --git a/gcc/d/toir.cc b/gcc/d/toir.cc index e0402a35c..c45d1d4ea 100644 --- a/gcc/d/toir.cc +++ b/gcc/d/toir.cc @@ -785,13 +785,14 @@ class IRVisitor : public Visitor this->start_scope(level_catch); tree catchtype = build_ctype(vcatch->type); + + // Get D's internal exception Object, different from the generic + // exception pointer returned from gcc runtime. + tree ehptr = d_build_call_nary(builtin_decl_explicit(BUILT_IN_EH_POINTER), + 1, integer_zero_node); + tree object = build_libcall(LIBCALL_BEGIN_CATCH, 1, &ehptr); if (vcatch->var) { - // Get D's internal exception Object, different - // from the generic exception pointer. - tree ehptr = d_build_call_nary(builtin_decl_explicit(BUILT_IN_EH_POINTER), - 1, integer_zero_node); - tree object = build_libcall(LIBCALL_BEGIN_CATCH, 1, &ehptr); object = build1(NOP_EXPR, build_ctype(build_object_type()), object); object = convert_expr(object, build_object_type(), vcatch->type); @@ -801,6 +802,12 @@ class IRVisitor : public Visitor build_local_var(vcatch->var); add_stmt(init); } + else + { + // Still need to emit a call to __gdc_begin_catch() to remove + // the object from the uncaught exceptions list. + add_stmt(object); + } if (vcatch->handler) vcatch->handler->accept(this);