aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimplify.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@airs.com>2005-01-21 19:05:23 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2005-01-21 19:05:23 +0000
commit089efaa4a16ff50c6c5b37e9f7add71f20c18f1b (patch)
tree29a38b973974253486c46f8b085f055eee2e1e15 /gcc/gimplify.c
parentd284eb28eb6f3ef8c3f27e7428b8cdc8e51d965f (diff)
downloadgcc-089efaa4a16ff50c6c5b37e9f7add71f20c18f1b.zip
gcc-089efaa4a16ff50c6c5b37e9f7add71f20c18f1b.tar.gz
gcc-089efaa4a16ff50c6c5b37e9f7add71f20c18f1b.tar.bz2
re PR tree-optimization/13000 ([unit-at-a-time] Using -O2 cannot detect missing return statement in a function)
PR tree-optimization/13000 * tree-inline.c: Include "tree-flow.h". (expand_call_inline): If warn_return_type, warn if non-void inline function falls through. * tree-cfg.c (execute_warn_function_return): Don't warn about control reaching end if TREE_NO_WARNING is set. Set TREE_NO_WARNING. * gimple-low.c (block_may_fallthru): Don't assume that SWITCH_EXPR has been lowered. * gimplify.c (shortcut_cond_expr): Don't emit a jump over the else branch if we don't need one. * c-typeck.c: Include "tree-flow.h" (c_finish_bc_stmt): Don't add a goto if the current statement list doesn't fall through to the current point. From-SVN: r94024
Diffstat (limited to 'gcc/gimplify.c')
-rw-r--r--gcc/gimplify.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index 12822c4..60d3572 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1911,7 +1911,7 @@ shortcut_cond_expr (tree expr)
tree true_label, false_label, end_label, t;
tree *true_label_p;
tree *false_label_p;
- bool emit_end, emit_false;
+ bool emit_end, emit_false, jump_over_else;
bool then_se = then_ && TREE_SIDE_EFFECTS (then_);
bool else_se = else_ && TREE_SIDE_EFFECTS (else_);
@@ -2013,6 +2013,16 @@ shortcut_cond_expr (tree expr)
emit_end = (end_label == NULL_TREE);
emit_false = (false_label == NULL_TREE);
+ /* We only emit the jump over the else clause if we have to--if the
+ then clause may fall through. Otherwise we can wind up with a
+ useless jump and a useless label at the end of gimplified code,
+ which will cause us to think that this conditional as a whole
+ falls through even if it doesn't. If we then inline a function
+ which ends with such a condition, that can cause us to issue an
+ inappropriate warning about control reaching the end of a
+ non-void function. */
+ jump_over_else = block_may_fallthru (then_);
+
pred = shortcut_cond_r (pred, true_label_p, false_label_p);
expr = NULL;
@@ -2021,8 +2031,11 @@ shortcut_cond_expr (tree expr)
append_to_statement_list (then_, &expr);
if (else_se)
{
- t = build_and_jump (&end_label);
- append_to_statement_list (t, &expr);
+ if (jump_over_else)
+ {
+ t = build_and_jump (&end_label);
+ append_to_statement_list (t, &expr);
+ }
if (emit_false)
{
t = build1 (LABEL_EXPR, void_type_node, false_label);