summaryrefslogtreecommitdiff
path: root/gcc/c-typeck.c
diff options
context:
space:
mode:
authorian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2005-01-21 19:05:23 +0000
committerian <ian@138bc75d-0d04-0410-961f-82ee72b054a4>2005-01-21 19:05:23 +0000
commit7f0f308dcade9eae784cde48b97fcb750195d95e (patch)
tree29a38b973974253486c46f8b085f055eee2e1e15 /gcc/c-typeck.c
parenta47b9d7927305dd956767900ce235bffc4e9310d (diff)
downloadgcc-7f0f308dcade9eae784cde48b97fcb750195d95e.tar.gz
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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@94024 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/c-typeck.c')
-rw-r--r--gcc/c-typeck.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/gcc/c-typeck.c b/gcc/c-typeck.c
index 186cb62bd2a..a4e4bc9df26 100644
--- a/gcc/c-typeck.c
+++ b/gcc/c-typeck.c
@@ -43,6 +43,7 @@ Software Foundation, 59 Temple Place - Suite 330, Boston, MA
#include "target.h"
#include "tree-iterator.h"
#include "tree-gimple.h"
+#include "tree-flow.h"
/* Possible cases of implicit bad conversions. Used to select
diagnostic messages in convert_for_assignment. */
@@ -6762,10 +6763,23 @@ c_finish_loop (location_t start_locus, tree cond, tree incr, tree body,
tree
c_finish_bc_stmt (tree *label_p, bool is_break)
{
+ bool skip;
tree label = *label_p;
+ /* In switch statements break is sometimes stylistically used after
+ a return statement. This can lead to spurious warnings about
+ control reaching the end of a non-void function when it is
+ inlined. Note that we are calling block_may_fallthru with
+ language specific tree nodes; this works because
+ block_may_fallthru returns true when given something it does not
+ understand. */
+ skip = !block_may_fallthru (cur_stmt_list);
+
if (!label)
- *label_p = label = create_artificial_label ();
+ {
+ if (!skip)
+ *label_p = label = create_artificial_label ();
+ }
else if (TREE_CODE (label) != LABEL_DECL)
{
if (is_break)
@@ -6775,6 +6789,9 @@ c_finish_bc_stmt (tree *label_p, bool is_break)
return NULL_TREE;
}
+ if (skip)
+ return NULL_TREE;
+
return add_stmt (build1 (GOTO_EXPR, void_type_node, label));
}