aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/parser.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2022-01-05 17:01:12 -0500
committerJason Merrill <jason@redhat.com>2022-01-06 19:25:43 -0500
commitb10e031458d541f794dfaa08ba606487603a4bb6 (patch)
tree84098539237e443920e3c21668370bb63a27c841 /gcc/cp/parser.c
parent4c6afbbd48f0c40ddf949bc403d9bd5f5e14204f (diff)
downloadgcc-b10e031458d541f794dfaa08ba606487603a4bb6.zip
gcc-b10e031458d541f794dfaa08ba606487603a4bb6.tar.gz
gcc-b10e031458d541f794dfaa08ba606487603a4bb6.tar.bz2
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.
Diffstat (limited to 'gcc/cp/parser.c')
-rw-r--r--gcc/cp/parser.c3
1 files changed, 0 insertions, 3 deletions
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 6b91a0c..f40e707 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -12751,9 +12751,6 @@ cp_parser_compound_statement (cp_parser *parser, tree in_statement_expr,
/* Parse an (optional) statement-seq. */
cp_parser_statement_seq_opt (parser, in_statement_expr);
- if (function_body)
- maybe_splice_retval_cleanup (compound_stmt);
-
/* Consume the `}'. */
braces.require_close (parser);