PR c++/33799 - destroy return value, take 2.
authorJason Merrill <jason@redhat.com>
Sun, 19 Jan 2020 14:14:54 +0000 (09:14 -0500)
committerJason Merrill <jason@redhat.com>
Sun, 19 Jan 2020 18:56:22 +0000 (13:56 -0500)
commitbcfc2227c556f2801a657ce3007374732baa8333
treedc5c76be5ccee189500336763b3b157b7942ac47
parent303484a73541ea7f41dff0238157924e49c255ff
PR c++/33799 - destroy return value, take 2.

This patch differs from the reverted patch for 33799 in that it adds the
CLEANUP_STMT for the return value at the end of the function, and only if
we've seen a cleanup that might throw, so it should not affect most C++11
code.

* cp-tree.h (current_retval_sentinel): New macro.
(struct language_function): Add throwing_cleanup bitfield.
* decl.c (cxx_maybe_build_cleanup): Set it.
* except.c (maybe_set_retval_sentinel)
(maybe_splice_retval_cleanup): New functions.
* parser.c (cp_parser_compound_statement): Call
maybe_splice_retval_cleanup.
* typeck.c (check_return_expr): Call maybe_set_retval_sentinel.
gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/except.c
gcc/cp/parser.c
gcc/cp/typeck.c
gcc/testsuite/g++.dg/eh/return1.C