diff options
author | Jason Merrill <jason@redhat.com> | 2020-01-10 17:14:12 -0500 |
---|---|---|
committer | Jason Merrill <jason@redhat.com> | 2020-01-13 12:50:12 -0500 |
commit | 7c82dd6c02d44d9d2cd84dda137c00b1a3cd6c90 (patch) | |
tree | d5bf3e04c5a748eb795b36dd2aa133add540fa74 /gcc/cp/mangle.c | |
parent | f1acad4e43908e90ca2b5155a878639cbea4c4e1 (diff) | |
download | gcc-7c82dd6c02d44d9d2cd84dda137c00b1a3cd6c90.zip gcc-7c82dd6c02d44d9d2cd84dda137c00b1a3cd6c90.tar.gz gcc-7c82dd6c02d44d9d2cd84dda137c00b1a3cd6c90.tar.bz2 |
PR c++/33799 - destroy return value if local cleanup throws.
This is a pretty rare situation since the C++11 change to make all
destructors default to noexcept, but it is still possible to define throwing
destructors, and if a destructor for a local variable throws during the
return, we've already constructed the return value, so now we need to
destroy it. I handled this somewhat like the new-expression cleanup; as in
that case, this cleanup can't properly nest with the cleanups for local
variables, so I introduce a cleanup region around the whole function and a
flag variable to indicate whether the return value actually needs to be
destroyed.
Setting the flag requires giving a COMPOUND_EXPR as the operand of a
RETURN_EXPR, so I adjust gimplify_return_expr to handle that.
This doesn't currently work with deduced return type because we don't know
the type when we're deciding whether to introduce the cleanup region.
gcc/
* gimplify.c (gimplify_return_expr): Handle COMPOUND_EXPR.
gcc/cp/
* cp-tree.h (current_retval_sentinel): New macro.
* decl.c (start_preparsed_function): Set up cleanup for retval.
* typeck.c (check_return_expr): Set current_retval_sentinel.
Diffstat (limited to 'gcc/cp/mangle.c')
0 files changed, 0 insertions, 0 deletions