Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Commit

Permalink
Always emit call to LIBCALL_BEGIN_CATCH at the start of the catch
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Aug 22, 2015
1 parent 3fffe1c commit 0e0cdc6
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
5 changes: 5 additions & 0 deletions gcc/d/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2015-08-22 Iain Buclaw <[email protected]>

* toir.cc(IRVisitor::visit(TryCatchStatement)): Always emit call to
LIBCALL_BEGIN_CATCH at the start of the catch.

2015-08-20 Iain Buclaw <[email protected]>

* toir.cc(IRVisitor::visit): Set input location in all visitors that
Expand Down
17 changes: 12 additions & 5 deletions gcc/d/toir.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);
Expand Down

0 comments on commit 0e0cdc6

Please sign in to comment.