aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Hainque <hainque@adacore.com>2015-01-07 09:49:24 +0000
committerArnaud Charlet <charlet@gcc.gnu.org>2015-01-07 10:49:24 +0100
commit1a9ee22281e0902c673d3c2e4cb5b83e07786569 (patch)
treed0faf93eb5ec15b59f7153b9d4f6e78dd71a2fae
parent7d1286f61e043074327839d3f2cd1c8d0039c3dc (diff)
downloadgcc-1a9ee22281e0902c673d3c2e4cb5b83e07786569.zip
gcc-1a9ee22281e0902c673d3c2e4cb5b83e07786569.tar.gz
gcc-1a9ee22281e0902c673d3c2e4cb5b83e07786569.tar.bz2
trans.c (gnat_to_gnu, [...]): Elaborate the expression as part of the same stmt group as the actions.
2015-01-07 Olivier Hainque <hainque@adacore.com> * gcc-interface/trans.c (gnat_to_gnu, <N_Expression_With_Action>): Elaborate the expression as part of the same stmt group as the actions. From-SVN: r219286
-rw-r--r--gcc/ada/ChangeLog5
-rw-r--r--gcc/ada/gcc-interface/trans.c19
2 files changed, 19 insertions, 5 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 6a752d2..0965f21 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,8 @@
+2015-01-07 Olivier Hainque <hainque@adacore.com>
+
+ * gcc-interface/trans.c (gnat_to_gnu, <N_Expression_With_Action>):
+ Elaborate the expression as part of the same stmt group as the actions.
+
2015-01-07 Robert Dewar <dewar@adacore.com>
* sem_ch3.adb: Minor error message change.
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index a91c0c8..e77aee0 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -7128,13 +7128,22 @@ gnat_to_gnu (Node_Id gnat_node)
/****************/
case N_Expression_With_Actions:
- /* 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);
+ /* 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. Elaborate the expression as part of the
+ same statement group as the actions so that the type declaration
+ gets inserted there as well. This ensures that the type elaboration
+ code is issued past the actions computing values on which it might
+ depend. */
+
+ start_stmt_group ();
+ add_stmt_list (Actions (gnat_node));
+ gnu_expr = gnat_to_gnu (Expression (gnat_node));
+ gnu_result = end_stmt_group ();
+
gnu_result = build1 (SAVE_EXPR, void_type_node, gnu_result);
TREE_SIDE_EFFECTS (gnu_result) = 1;
- gnu_expr = gnat_to_gnu (Expression (gnat_node));
+
gnu_result
= build_compound_expr (TREE_TYPE (gnu_expr), gnu_result, gnu_expr);
gnu_result_type = get_unpadded_type (Etype (gnat_node));