aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/trans.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2012-07-18 12:20:06 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2012-07-18 12:20:06 +0000
commita712b009c56fde0f26e757509b1019d6fb7b6ed6 (patch)
treef5f56fec465806d6c16572fa83015e989dc46ef8 /gcc/ada/gcc-interface/trans.c
parentedd5e90012b96ce9c2f9ff3837561e51aa509ebd (diff)
downloadgcc-a712b009c56fde0f26e757509b1019d6fb7b6ed6.zip
gcc-a712b009c56fde0f26e757509b1019d6fb7b6ed6.tar.gz
gcc-a712b009c56fde0f26e757509b1019d6fb7b6ed6.tar.bz2
trans.c (stmt_group_may_fallthru): New function.
* gcc-interface/trans.c (stmt_group_may_fallthru): New function. (gnat_to_gnu) <N_Block_Statement>: Use it to find out whether the block needs to be translated. From-SVN: r189612
Diffstat (limited to 'gcc/ada/gcc-interface/trans.c')
-rw-r--r--gcc/ada/gcc-interface/trans.c30
1 files changed, 24 insertions, 6 deletions
diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c
index 08a263a..95b83fe 100644
--- a/gcc/ada/gcc-interface/trans.c
+++ b/gcc/ada/gcc-interface/trans.c
@@ -244,6 +244,7 @@ static void add_cleanup (tree, Node_Id);
static void add_stmt_list (List_Id);
static void push_exception_label_stack (VEC(tree,gc) **, Entity_Id);
static tree build_stmt_group (List_Id, bool);
+static inline bool stmt_group_may_fallthru (void);
static enum gimplify_status gnat_gimplify_stmt (tree *);
static void elaborate_all_entities (Node_Id);
static void process_freeze_entity (Node_Id);
@@ -6197,12 +6198,18 @@ gnat_to_gnu (Node_Id gnat_node)
break;
case N_Block_Statement:
- start_stmt_group ();
- gnat_pushlevel ();
- process_decls (Declarations (gnat_node), Empty, Empty, true, true);
- add_stmt (gnat_to_gnu (Handled_Statement_Sequence (gnat_node)));
- gnat_poplevel ();
- gnu_result = end_stmt_group ();
+ /* The only way to enter the block is to fall through to it. */
+ if (stmt_group_may_fallthru ())
+ {
+ start_stmt_group ();
+ gnat_pushlevel ();
+ process_decls (Declarations (gnat_node), Empty, Empty, true, true);
+ add_stmt (gnat_to_gnu (Handled_Statement_Sequence (gnat_node)));
+ gnat_poplevel ();
+ gnu_result = end_stmt_group ();
+ }
+ else
+ gnu_result = alloc_stmt_list ();
break;
case N_Exit_Statement:
@@ -7240,6 +7247,17 @@ end_stmt_group (void)
return gnu_retval;
}
+/* Return whether the current statement group may fall through. */
+
+static inline bool
+stmt_group_may_fallthru (void)
+{
+ if (current_stmt_group->stmt_list)
+ return block_may_fallthru (current_stmt_group->stmt_list);
+ else
+ return true;
+}
+
/* Add a list of statements from GNAT_LIST, a possibly-empty list of
statements.*/