From ebebc928d8b0d17676e751848892f927373b1fe5 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Thu, 4 Jul 2019 15:00:00 +0000 Subject: introduce EH_ELSE_EXPR tree and gimplifier I found GIMPLE_EH_ELSE offered exactly the semantics I needed for some Ada changes yet to be contributed, but GIMPLE_EH_ELSE was only built by GIMPLE passes, and I needed to build earlier something that eventually became GIMPLE_EH_ELSE. This patch does that, introducing an EH_ELSE_EXPR tree, and logic to dump it and to gimplify it. for gcc/ChangeLog * doc/generic.texi (Cleanups): Document EH_ELSE_EXPR. * except.c: Likewise. * expr.c (expand_expr_real_1): Reject it. * gimplify.c (gimplify_expr): Gimplify it, within TRY_FINALLY_EXPR. * tree-dump.c (dequeue_and_dump): Dump it. * tree-pretty-print.c (dump_generic_node): Likewise. * tree.c (block_may_fallthru): Handle it. * tree.def (EH_ELSE_EXPR): Introduce it. * gimple-pretty-print.c (dump_gimple_try): Dump TRY_FINALLY with GIMPLE_EH_ELSE as try/finally/else. From-SVN: r273084 --- gcc/tree-pretty-print.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'gcc/tree-pretty-print.c') diff --git a/gcc/tree-pretty-print.c b/gcc/tree-pretty-print.c index dacda7b..742c284 100644 --- a/gcc/tree-pretty-print.c +++ b/gcc/tree-pretty-print.c @@ -2815,12 +2815,34 @@ dump_generic_node (pretty_printer *pp, tree node, int spc, dump_flags_t flags, newline_and_indent (pp, spc+2); pp_right_brace (pp); newline_and_indent (pp, spc); - pp_string (pp, - (TREE_CODE (node) == TRY_CATCH_EXPR) ? "catch" : "finally"); + if (TREE_CODE (node) == TRY_CATCH_EXPR) + { + node = TREE_OPERAND (node, 1); + pp_string (pp, "catch"); + } + else + { + gcc_assert (TREE_CODE (node) == TRY_FINALLY_EXPR); + node = TREE_OPERAND (node, 1); + pp_string (pp, "finally"); + if (TREE_CODE (node) == EH_ELSE_EXPR) + { + newline_and_indent (pp, spc+2); + pp_left_brace (pp); + newline_and_indent (pp, spc+4); + dump_generic_node (pp, TREE_OPERAND (node, 0), spc+4, + flags, true); + newline_and_indent (pp, spc+2); + pp_right_brace (pp); + newline_and_indent (pp, spc); + node = TREE_OPERAND (node, 1); + pp_string (pp, "else"); + } + } newline_and_indent (pp, spc+2); pp_left_brace (pp); newline_and_indent (pp, spc+4); - dump_generic_node (pp, TREE_OPERAND (node, 1), spc+4, flags, true); + dump_generic_node (pp, node, spc+4, flags, true); newline_and_indent (pp, spc+2); pp_right_brace (pp); is_expr = false; -- cgit v1.1