/* We now know that the final suspend object is distinct from the
final awaiter, so check for a non-throwing DTOR where needed. */
- tree a_type = TREE_TYPE (a);
- if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (a_type))
- if (tree dummy
- = build_special_member_call (a, complete_dtor_identifier,
- NULL, a_type, LOOKUP_NORMAL,
- tf_none))
- {
- if (CONVERT_EXPR_P (dummy))
- dummy = TREE_OPERAND (dummy, 0);
- dummy = TREE_OPERAND (CALL_EXPR_FN (dummy), 0);
- if (coro_diagnose_throwing_fn (dummy))
- return error_mark_node;
- }
+ if (tree dummy = cxx_maybe_build_cleanup (a, tf_none))
+ {
+ if (CONVERT_EXPR_P (dummy))
+ dummy = TREE_OPERAND (dummy, 0);
+ dummy = TREE_OPERAND (CALL_EXPR_FN (dummy), 0);
+ if (coro_diagnose_throwing_fn (dummy))
+ return error_mark_node;
+ }
}
}
else
return error_mark_node;
if (coro_diagnose_throwing_fn (awrs_func))
return error_mark_node;
- if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (o_type))
- if (tree dummy
- = build_special_member_call (e_proxy, complete_dtor_identifier,
- NULL, o_type, LOOKUP_NORMAL,
- tf_none))
- {
- if (CONVERT_EXPR_P (dummy))
- dummy = TREE_OPERAND (dummy, 0);
- dummy = TREE_OPERAND (CALL_EXPR_FN (dummy), 0);
- if (coro_diagnose_throwing_fn (dummy))
- return error_mark_node;
- }
+ if (tree dummy = cxx_maybe_build_cleanup (e_proxy, tf_none))
+ {
+ if (CONVERT_EXPR_P (dummy))
+ dummy = TREE_OPERAND (dummy, 0);
+ dummy = TREE_OPERAND (CALL_EXPR_FN (dummy), 0);
+ if (coro_diagnose_throwing_fn (dummy))
+ return error_mark_node;
+ }
}
/* We now have three call expressions, in terms of the promise, handle and
tree resume_label = create_named_label_with_ctx (loc, buf, actor);
tree empty_list = build_empty_stmt (loc);
- tree await_type = TREE_TYPE (var);
tree stmt_list = NULL;
tree r;
tree *await_init = NULL;
append_to_statement_list (destroy_label, &body_list);
if (needs_dtor)
{
- tree dtor = build_special_member_call (var, complete_dtor_identifier,
- NULL, await_type, LOOKUP_NORMAL,
- tf_warning_or_error);
+ tree dtor = build_cleanup (var);
append_to_statement_list (dtor, &body_list);
}
r = build1_loc (loc, GOTO_EXPR, void_type_node, data->cleanup);
tree *revised = tsi_stmt_ptr (tsi_last (stmt_list));
if (needs_dtor)
{
- tree dtor = build_special_member_call (var, complete_dtor_identifier,
- NULL, await_type, LOOKUP_NORMAL,
- tf_warning_or_error);
+ tree dtor = build_cleanup (var);
append_to_statement_list (dtor, &stmt_list);
}
data->index += 2;
add_stmt (r);
/* Destructors for the things we built explicitly. */
- r = build_special_member_call (promise_proxy, complete_dtor_identifier, NULL,
- promise_type, LOOKUP_NORMAL,
- tf_warning_or_error);
- add_stmt (r);
+ if (tree c = cxx_maybe_build_cleanup (promise_proxy, tf_warning_or_error))
+ add_stmt (c);
tree del_frame_label
= create_named_label_with_ctx (loc, "coro.delete.frame", actor);
= lookup_member (coro_frame_type, pid, 1, 0, tf_warning_or_error);
tree a = build_class_member_access_expr (actor_frame, m, NULL_TREE,
false, tf_warning_or_error);
- tree t = TREE_TYPE (a);
- tree dtor;
- dtor
- = build_special_member_call (a, complete_dtor_identifier, NULL, t,
- LOOKUP_NORMAL, tf_warning_or_error);
- add_stmt (dtor);
+ if (tree dtor = cxx_maybe_build_cleanup (a, tf_warning_or_error))
+ add_stmt (dtor);
}
}
tree *flag = var_flags.get (var);
if (!flag)
continue;
- tree var_type = TREE_TYPE (var);
- tree cleanup
- = build_special_member_call (var, complete_dtor_identifier,
- NULL, var_type, LOOKUP_NORMAL,
- tf_warning_or_error);
- tree cond_cleanup = begin_if_stmt ();
- finish_if_stmt_cond (*flag, cond_cleanup);
- finish_expr_stmt (cleanup);
- finish_then_clause (cond_cleanup);
- finish_if_stmt (cond_cleanup);
+ if (tree cleanup = cxx_maybe_build_cleanup (var, tf_warning_or_error))
+ {
+ tree cond_cleanup = begin_if_stmt ();
+ finish_if_stmt_cond (*flag, cond_cleanup);
+ finish_expr_stmt (cleanup);
+ finish_then_clause (cond_cleanup);
+ finish_if_stmt (cond_cleanup);
+ }
}
final_actions = pop_stmt_list (final_actions);
tree try_finally
process_conditional (t, vlist);
else
finish_expr_stmt (t->init);
- tree var_type = TREE_TYPE (var);
- if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (var_type))
+ if (tree cleanup = cxx_maybe_build_cleanup (var, tf_warning_or_error))
{
- tree cleanup
- = build_special_member_call (var, complete_dtor_identifier,
- NULL, var_type, LOOKUP_NORMAL,
- tf_warning_or_error);
tree cl = build_stmt (sloc, CLEANUP_STMT, expr_list, cleanup, var);
add_stmt (cl); /* push this onto the level above. */
}
vec_safe_push (param_dtor_list, parm.field_id);
/* Cleanup this frame copy on exception. */
parm.fr_copy_dtor
- = build_special_member_call (fld_idx, complete_dtor_identifier,
- NULL, parm.frame_type,
- LOOKUP_NORMAL,
- tf_warning_or_error);
+ = cxx_maybe_build_cleanup (fld_idx, tf_warning_or_error);
if (flag_exceptions)
{
/* This var is now live. */
boolean_type_node);
finish_expr_stmt (r);
- promise_dtor
- = build_special_member_call (p, complete_dtor_identifier,
- NULL, promise_type, LOOKUP_NORMAL,
- tf_warning_or_error);
+ promise_dtor = cxx_maybe_build_cleanup (p, tf_warning_or_error);
}
/* Set up a new bind context for the GRO. */
/* If some part of the initalization code (prior to the await_resume
of the initial suspend expression), then we need to clean up the
return value. */
- gro_ret_dtor
- = build_special_member_call (DECL_RESULT (orig),
- complete_dtor_identifier, NULL,
- gro_type, LOOKUP_NORMAL,
- tf_warning_or_error);
+ gro_ret_dtor = cxx_maybe_build_cleanup (DECL_RESULT (orig),
+ tf_warning_or_error);
}
else
{
r = cp_build_modify_expr (input_location, gro, INIT_EXPR, get_ro,
tf_warning_or_error);
/* The constructed object might require a cleanup. */
- if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (gro_type))
- {
- gro_cleanup_stmt
- = build_special_member_call (gro, complete_dtor_identifier,
- NULL, gro_type, LOOKUP_NORMAL,
- tf_warning_or_error);
- gro_cleanup_stmt = build_stmt (input_location, CLEANUP_STMT, NULL,
- gro_cleanup_stmt, gro);
- }
+ if (tree cleanup = cxx_maybe_build_cleanup (gro, tf_warning_or_error))
+ gro_cleanup_stmt = build_stmt (input_location, CLEANUP_STMT, NULL,
+ cleanup, gro);
}
finish_expr_stmt (r);