summaryrefslogtreecommitdiffstats
path: root/gcc/gimple-low.c
diff options
context:
space:
mode:
authorrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-19 05:39:14 +0000
committerrth <rth@138bc75d-0d04-0410-961f-82ee72b054a4>2004-06-19 05:39:14 +0000
commit751ddc2be835ee78d30b7f5d90db6945cffba982 (patch)
tree5791e7f8af3ac3bb999dd5a105aafb41d29af09e /gcc/gimple-low.c
parentb040cc053d1e0a0a9b4b33f604eb0468fee5be49 (diff)
downloadppe42-gcc-751ddc2be835ee78d30b7f5d90db6945cffba982.tar.gz
ppe42-gcc-751ddc2be835ee78d30b7f5d90db6945cffba982.zip
PR c++/16036
* gimple-low.c (lower_function_body): Generate return statement for fall off the end of the function here ... * tree-cfg.c (make_edges): ... instead of here. * gimplify.c (gimplify_return_expr): Mark return temp TREE_NO_WARNING. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@83382 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple-low.c')
-rw-r--r--gcc/gimple-low.c43
1 files changed, 26 insertions, 17 deletions
diff --git a/gcc/gimple-low.c b/gcc/gimple-low.c
index aac3341b8cc..98346cc2bf2 100644
--- a/gcc/gimple-low.c
+++ b/gcc/gimple-low.c
@@ -67,6 +67,7 @@ lower_function_body (void)
tree *body_p = &DECL_SAVED_TREE (current_function_decl);
tree bind = *body_p;
tree_stmt_iterator i;
+ tree t, x;
if (TREE_CODE (bind) != BIND_EXPR)
abort ();
@@ -83,25 +84,33 @@ lower_function_body (void)
tsi_link_after (&i, bind, TSI_NEW_STMT);
lower_bind_expr (&i, &data);
- /* If we lowered any return statements, emit the representative at the
- end of the function. */
- if (data.return_statements)
+ i = tsi_last (*body_p);
+
+ /* If the function falls off the end, we need a null return statement.
+ If we've already got one in the return_statements list, we don't
+ need to do anything special. Otherwise build one by hand. */
+ if (block_may_fallthru (*body_p)
+ && (data.return_statements == NULL
+ || TREE_OPERAND (TREE_VALUE (data.return_statements), 0) != NULL))
{
- tree t, x;
- i = tsi_last (*body_p);
+ x = build (RETURN_EXPR, void_type_node, NULL);
+ annotate_with_locus (x, cfun->function_end_locus);
+ tsi_link_after (&i, x, TSI_CONTINUE_LINKING);
+ }
- for (t = data.return_statements; t ; t = TREE_CHAIN (t))
- {
- x = build (LABEL_EXPR, void_type_node, TREE_PURPOSE (t));
- tsi_link_after (&i, x, TSI_CONTINUE_LINKING);
-
- /* Remove the line number from the representative return statement.
- It now fills in for many such returns. Failure to remove this
- will result in incorrect results for coverage analysis. */
- x = TREE_VALUE (t);
- SET_EXPR_LOCUS (x, NULL);
- tsi_link_after (&i, x, TSI_CONTINUE_LINKING);
- }
+ /* If we lowered any return statements, emit the representative
+ at the end of the function. */
+ for (t = data.return_statements ; t ; t = TREE_CHAIN (t))
+ {
+ x = build (LABEL_EXPR, void_type_node, TREE_PURPOSE (t));
+ tsi_link_after (&i, x, TSI_CONTINUE_LINKING);
+
+ /* Remove the line number from the representative return statement.
+ It now fills in for many such returns. Failure to remove this
+ will result in incorrect results for coverage analysis. */
+ x = TREE_VALUE (t);
+ SET_EXPR_LOCUS (x, NULL);
+ tsi_link_after (&i, x, TSI_CONTINUE_LINKING);
}
if (data.block != DECL_INITIAL (current_function_decl))
OpenPOWER on IntegriCloud