diff options
author | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-12-04 11:11:56 +0000 |
---|---|---|
committer | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-12-04 11:11:56 +0000 |
commit | 42f6cff195a783e3de220c83b3d1503795d430c4 (patch) | |
tree | a9c83bb498c53c5a70e1f2b28addca926c4699b6 | |
parent | 8c1dfa9438b159a6ebb683da469978761a4dcd31 (diff) | |
download | ppe42-gcc-42f6cff195a783e3de220c83b3d1503795d430c4.tar.gz ppe42-gcc-42f6cff195a783e3de220c83b3d1503795d430c4.zip |
* gcc-interface/trans.c (Case_Statement_to_gnu): Do not push a binding
level for each branch if this is a case expression in Ada 2012.
(gnat_to_gnu) <case N_Expression_With_Actions>: Adjust comment.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205662 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ada/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 17 |
2 files changed, 17 insertions, 6 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index f1f73169933..504f358a782 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2013-12-04 Eric Botcazou <ebotcazou@adacore.com> + + * gcc-interface/trans.c (Case_Statement_to_gnu): Do not push a binding + level for each branch if this is a case expression in Ada 2012. + (gnat_to_gnu) <case N_Expression_With_Actions>: Adjust comment. + 2013-11-29 Eric Botcazou <ebotcazou@adacore.com> PR ada/54040 diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index e533de6dcbf..2eae39976d8 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -2348,12 +2348,17 @@ Case_Statement_to_gnu (Node_Id gnat_node) } } - /* Push a binding level here in case variables are declared as we want - them to be local to this set of statements instead of to the block - containing the Case statement. */ + /* This construct doesn't define a scope so we shouldn't push a binding + level around the statement list. Except that we have always done so + historically and this makes it possible to reduce stack usage. As a + compromise, we keep doing it for case statements, for which this has + never been problematic, but not for case expressions in Ada 2012. */ if (choices_added_p) { - tree group = build_stmt_group (Statements (gnat_when), true); + const bool is_case_expression + = (Nkind (Parent (gnat_node)) == N_Expression_With_Actions); + tree group + = build_stmt_group (Statements (gnat_when), !is_case_expression); bool group_may_fallthru = block_may_fallthru (group); add_stmt (group); if (group_may_fallthru) @@ -7002,8 +7007,8 @@ gnat_to_gnu (Node_Id gnat_node) /****************/ case N_Expression_With_Actions: - /* This construct doesn't define a scope so we don't wrap the statement - list in a BIND_EXPR; however, we wrap it in a SAVE_EXPR to protect it + /* This construct doesn't define a scope so we don't push a binding level + around the statement list; but we wrap it in a SAVE_EXPR to protect it from unsharing. */ gnu_result = build_stmt_group (Actions (gnat_node), false); gnu_result = build1 (SAVE_EXPR, void_type_node, gnu_result); |