From 65791f426fc950b0af4e6e2ef675c213e623b16f Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Fri, 1 Dec 2017 09:17:06 +0100 Subject: re PR c/79153 (-Wimplicit-fallthrough missed warning) PR c/79153 * tree.h (SWITCH_BREAK_LABEL_P): Define. * gimplify.c (collect_fallthrough_labels): Handle GIMPLE_BIND starting with a GIMPLE_SWITCH and ending with GIMPLE_LABEL with SWITCH_BREAK_LABEL_P set on the label. (gimplify_switch_expr): Set SWITCH_BREAK_LABEL_P on the label added for default case if it was missing and not all cases covered. Wrap GIMPLE_SWITCH and the switch_body_seq into a GIMPLE_BIND if switch_body_seq ends with a GIMPLE_LABEL with SWITCH_BREAK_LABEL_P set on the label. * tree-chrec.c (evolution_function_is_univariate_p): Add return true; to avoid -Wimplicit-fallthrough warning. * config/i386/i386.c (ix86_expand_special_args_builtin): Add FALLTHRU comment to avoid -Wimplicit-fallthrough warning. c/ * c-parser.c: Include tree-iterator.h. (c_parser_switch_statement): Emit LABEL_EXPR for the break label into SWITCH_BODY instead of after it and set SWITCH_BREAK_LABEL_P on it. cp/ * cp-gimplify.c (genericize_switch_stmt): Emit LABEL_EXPR for the break label into SWITCH_BODY instead of after it and set SWITCH_BREAK_LABEL_P on it. * parser.c (cp_parser_objc_expression): Add FALLTHRU comment to avoid -Wimplicit-fallthrough warning. fortran/ * match.c (gfc_match): Add FALLTHRU comment to avoid -Wimplicit-fallthrough warning. testsuite/ * c-c++-common/Wimplicit-fallthrough-7.c: Adjust expected warning line. * c-c++-common/Wimplicit-fallthrough-36.c: New test. From-SVN: r255298 --- gcc/c/ChangeLog | 6 ++++++ gcc/c/c-parser.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'gcc/c') diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 90db38a..1fb0c3d 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,5 +1,11 @@ 2017-12-01 Jakub Jelinek + PR c/79153 + * c-parser.c: Include tree-iterator.h. + (c_parser_switch_statement): Emit LABEL_EXPR for the break label + into SWITCH_BODY instead of after it and set SWITCH_BREAK_LABEL_P + on it. + PR c/83222 * c-tree.h (decl_constant_value_1): Declare. * c-typeck.c (decl_constant_value_1): New function. diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c index 755cd2b..e9267fe 100644 --- a/gcc/c/c-parser.c +++ b/gcc/c/c-parser.c @@ -67,6 +67,7 @@ along with GCC; see the file COPYING3. If not see #include "run-rtl-passes.h" #include "intl.h" #include "c-family/name-hint.h" +#include "tree-iterator.h" /* We need to walk over decls with incomplete struct/union/enum types after parsing the whole translation unit. @@ -5846,14 +5847,15 @@ c_parser_switch_statement (c_parser *parser, bool *if_p) if (!open_brace_p && c_parser_peek_token (parser)->type != CPP_SEMICOLON) warn_for_multistatement_macros (loc_after_labels, next_loc, switch_loc, RID_SWITCH); - c_finish_case (body, ce.original_type); if (c_break_label) { location_t here = c_parser_peek_token (parser)->location; tree t = build1 (LABEL_EXPR, void_type_node, c_break_label); SET_EXPR_LOCATION (t, here); - add_stmt (t); + SWITCH_BREAK_LABEL_P (c_break_label) = 1; + append_to_statement_list_force (t, &body); } + c_finish_case (body, ce.original_type); c_break_label = save_break; add_stmt (c_end_compound_stmt (switch_loc, block, flag_isoc99)); c_parser_maybe_reclassify_token (parser); -- cgit v1.1