c++: destroy retval on throwing cleanup in try [PR33799]
My earlier attempt to fix this bug didn't handle the case where both the
return and the throwing cleanup are within a try-block that catches and
discards the exception. Fixed by adding the retval cleanup to any
try-blocks as well as the function body. PR102191 pointed out that we also
weren't handling templates properly, so I moved the call out of the parser.
PR c++/33799
PR c++/102191
gcc/cp/ChangeLog:
* except.c (maybe_splice_retval_cleanup): Check
current_binding_level.
* semantics.c (do_poplevel): Call it here.
* parser.c (cp_parser_compound_statement): Not here.
gcc/testsuite/ChangeLog:
* g++.dg/eh/return1.C: Add temporary in try block case.
* g++.dg/cpp2a/constexpr-dtor11.C: New test.