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

Commit

Permalink
Bug 118 - ICE in gimplifying TRY_CATCH_EXPR
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Apr 13, 2014
1 parent 7c6ac12 commit 3d820cd
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
3 changes: 3 additions & 0 deletions gcc/d/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
2014-04-13 Iain Buclaw <ibuclaw@gdcproject.org>

* d-codegen.cc(get_frameinfo): Don't copy the node for frame record.
* d-irstate.cc(IRState::endCatches): Rebuild the STATEMENT_LIST of
catches in a TRY_CATCH_EXPR if it gets optimised away by
IRState::popStatement.

2014-03-31 Iain Buclaw <ibuclaw@gdcproject.org>

Expand Down
15 changes: 12 additions & 3 deletions gcc/d/d-irstate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ IRState::addExp (tree e)
e = build1 (CONVERT_EXPR, void_type_node, e);
}

// C doesn't do this for label_exprs %% why?
if (EXPR_P (e) && !EXPR_HAS_LOCATION (e))
SET_EXPR_LOCATION (e, input_location);

Expand Down Expand Up @@ -141,6 +140,7 @@ IRState::popStatementList (void)
t = u;
}
}

return t;
}

Expand Down Expand Up @@ -573,8 +573,6 @@ void
IRState::endCatch (void)
{
tree body = this->popStatementList();
// % Wrong loc... can set pass statement to startCatch, set
// The loc on type and then use it here...
this->addExp (build2 (CATCH_EXPR, void_type_node,
this->currentFlow()->catchType, body));
}
Expand All @@ -587,6 +585,17 @@ IRState::endCatches (void)
Flow *flow = this->currentFlow();
tree catches = this->popStatementList();

/* Backend expects all catches in a TRY_CATCH_EXPR to be enclosed in a
statement list, however popStatementList may optimise away the list
if there is only a single catch to push. */
if (TREE_CODE (catches) != STATEMENT_LIST)
{
tree stmt_list = alloc_stmt_list();
append_to_statement_list_force (catches, &stmt_list);
d_keep (stmt_list);
catches = stmt_list;
}

this->doLineNote (flow->statement->loc);
this->addExp (build2 (TRY_CATCH_EXPR, void_type_node,
flow->tryBody, catches));
Expand Down

0 comments on commit 3d820cd

Please sign in to comment.