Accompanying changes to the core patch. 2016-08-22 Marek Polacek <pola...@redhat.com>
PR c/7652 * Makefile.in (insn-attrtab.o-warn, insn-dfatab.o-warn, insn-latencytab.o-warn, insn-output.o-warn, insn-emit.o-warn): Add -Wno-switch-fallthrough. * builtins.c (expand_builtin_int_roundingfn_2): Add gcc_fallthrough. (expand_builtin): Likewise. * config/rs6000/rs6000.c (rs6000_builtin_vectorized_libmass): Likewise. * convert.c (convert_to_real_1): Likewise. (convert_to_integer_1): Likewise. * final.c (output_alternate_entry_point): Likewise. * genattrtab.c (make_canonical): Likewise. (write_test_expr): Likewise. * genpreds.c (validate_exp): Likewise. * gimple-ssa-strength-reduction.c (find_candidates_dom_walker::before_dom_children): Likewise. * godump.c (go_format_type): Likewise. * reload1.c (elimination_effects): Likewise. * resource.c (mark_referenced_resources): Likewise. (mark_set_resources): Likewise. * tree-ssa-loop-ivopts.c (find_deriving_biv_for_expr): Likewise. * varasm.c (output_addressed_constants): Likewise. gcc/c-family/ * c-common.c (resolve_overloaded_builtin): Add gcc_fallthrough. gcc/c/ * c-decl.c (pop_scope): Add gcc_fallthrough. * c-typeck.c (composite_type): Likewise. gcc/gcc/cp/ * error.c (dump_type): Add gcc_fallthrough. (dump_decl): Likewise. (dump_expr): Likewise. * parser.c (cp_parser_storage_class_specifier_opt): Likewise. (cp_parser_skip_to_end_of_template_parameter_list): Likewise. (cp_parser_cache_defarg): Likewise. (cp_parser_omp_for_cond): Likewise. * semantics.c (finish_decltype_type): Likewise. * typeck.c (structural_comptypes): Likewise. (cp_build_binary_op): Likewise. (cp_build_modify_expr): Likewise. gcc/fortran/ * arith.c (eval_intrinsic): Add gcc_fallthrough. * frontend-passes.c (optimize_op): Likewise. (gfc_expr_walker): Likewise. * parse.c (next_fixed): Likewise. * primary.c (match_variable): Likewise. * trans-array.c: Likewise. * trans-expr.c (flatten_array_ctors_without_strlen): Likewise. libstdc++-v3/ * libsupc++/hash_bytes.cc: Add [[gnu::fallthrough]]. --- gcc/gcc/Makefile.in +++ gcc/gcc/Makefile.in @@ -218,6 +218,11 @@ libgcov-merge-tool.o-warn = -Wno-error gimple-match.o-warn = -Wno-unused generic-match.o-warn = -Wno-unused dfp.o-warn = -Wno-strict-aliasing +insn-attrtab.o-warn = -Wno-implicit-fallthrough +insn-dfatab.o-warn = -Wno-implicit-fallthrough +insn-latencytab.o-warn = -Wno-implicit-fallthrough +insn-output.o-warn = -Wno-implicit-fallthrough +insn-emit.o-warn = -Wno-implicit-fallthrough # All warnings have to be shut off in stage1 if the compiler used then # isn't gcc; configure determines that. WARN_CFLAGS will be either --- gcc/gcc/builtins.c +++ gcc/gcc/builtins.c @@ -2587,7 +2587,7 @@ expand_builtin_int_roundingfn_2 (tree exp, rtx target) { CASE_FLT_FN (BUILT_IN_IRINT): fallback_fn = BUILT_IN_LRINT; - /* FALLTHRU */ + gcc_fallthrough (); CASE_FLT_FN (BUILT_IN_LRINT): CASE_FLT_FN (BUILT_IN_LLRINT): builtin_optab = lrint_optab; @@ -2595,7 +2595,7 @@ expand_builtin_int_roundingfn_2 (tree exp, rtx target) CASE_FLT_FN (BUILT_IN_IROUND): fallback_fn = BUILT_IN_LROUND; - /* FALLTHRU */ + gcc_fallthrough (); CASE_FLT_FN (BUILT_IN_LROUND): CASE_FLT_FN (BUILT_IN_LLROUND): builtin_optab = lround_optab; @@ -5902,6 +5902,7 @@ expand_builtin (tree exp, rtx target, rtx subtarget, machine_mode mode, CASE_FLT_FN (BUILT_IN_ILOGB): if (! flag_unsafe_math_optimizations) break; + gcc_fallthrough (); CASE_FLT_FN (BUILT_IN_ISINF): CASE_FLT_FN (BUILT_IN_FINITE): case BUILT_IN_ISFINITE: --- gcc/gcc/c-family/c-common.c +++ gcc/gcc/c-family/c-common.c @@ -11528,6 +11528,7 @@ resolve_overloaded_builtin (location_t loc, tree function, gcc_unreachable (); } /* Fallthrough to the normal processing. */ + gcc_fallthrough (); } case BUILT_IN_ATOMIC_EXCHANGE_N: case BUILT_IN_ATOMIC_COMPARE_EXCHANGE_N: @@ -11536,6 +11537,7 @@ resolve_overloaded_builtin (location_t loc, tree function, { fetch_op = false; /* Fallthrough to further processing. */ + gcc_fallthrough (); } case BUILT_IN_ATOMIC_ADD_FETCH_N: case BUILT_IN_ATOMIC_SUB_FETCH_N: @@ -11552,6 +11554,7 @@ resolve_overloaded_builtin (location_t loc, tree function, { orig_format = false; /* Fallthru for parameter processing. */ + gcc_fallthrough (); } case BUILT_IN_SYNC_FETCH_AND_ADD_N: case BUILT_IN_SYNC_FETCH_AND_SUB_N: --- gcc/gcc/c/c-decl.c +++ gcc/gcc/c/c-decl.c @@ -1328,7 +1328,7 @@ pop_scope (void) set_type_context (TREE_TYPE (p), context); } - /* Fall through. */ + gcc_fallthrough (); /* Parameters go in DECL_ARGUMENTS, not BLOCK_VARS, and have already been put there by store_parm_decls. Unused- parameter warnings are handled by function.c. --- gcc/gcc/c/c-typeck.c +++ gcc/gcc/c/c-typeck.c @@ -605,7 +605,7 @@ composite_type (tree t1, tree t2) t1 = build_function_type (valtype, newargs); t1 = qualify_type (t1, t2); - /* ... falls through ... */ + gcc_fallthrough (); } default: --- gcc/gcc/config/rs6000/rs6000.c +++ gcc/gcc/config/rs6000/rs6000.c @@ -5482,7 +5482,7 @@ rs6000_builtin_vectorized_libmass (combined_fn fn, tree type_out, CASE_CFN_HYPOT: CASE_CFN_POW: n_args = 2; - /* fall through */ + gcc_fallthrough (); CASE_CFN_ACOS: CASE_CFN_ACOSH: --- gcc/gcc/convert.c +++ gcc/gcc/convert.c @@ -164,6 +164,7 @@ convert_to_real_1 (tree type, tree expr, bool fold_p) -fmath-errno. */ if (flag_errno_math) break; + gcc_fallthrough (); CASE_MATHFN (ACOS) CASE_MATHFN (ACOSH) CASE_MATHFN (ASIN) @@ -184,6 +185,7 @@ convert_to_real_1 (tree type, tree expr, bool fold_p) /* The above functions are not safe to do this conversion. */ if (!flag_unsafe_math_optimizations) break; + gcc_fallthrough (); CASE_MATHFN (SQRT) CASE_MATHFN (FABS) CASE_MATHFN (LOGB) @@ -516,7 +518,7 @@ convert_to_integer_1 (tree type, tree expr, bool dofold) /* Only convert nearbyint* if we can ignore math exceptions. */ if (flag_trapping_math) break; - /* ... Fall through ... */ + gcc_fallthrough (); CASE_FLT_FN (BUILT_IN_RINT): /* Only convert in ISO C99 mode and with -fno-math-errno. */ if (!targetm.libc_has_function (function_c99_misc) || flag_errno_math) --- gcc/gcc/cp/error.c +++ gcc/gcc/cp/error.c @@ -576,6 +576,7 @@ dump_type (cxx_pretty_printer *pp, tree t, int flags) default: pp_unsupported_tree (pp, t); /* Fall through to error. */ + gcc_fallthrough (); case ERROR_MARK: pp_string (pp, M_("<type error>")); @@ -1277,6 +1278,7 @@ dump_decl (cxx_pretty_printer *pp, tree t, int flags) default: pp_unsupported_tree (pp, t); /* Fall through to error. */ + gcc_fallthrough (); case ERROR_MARK: pp_string (pp, M_("<declaration error>")); @@ -2778,6 +2780,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) default: pp_unsupported_tree (pp, t); /* fall through to ERROR_MARK... */ + gcc_fallthrough (); case ERROR_MARK: pp_string (pp, M_("<expression error>")); break; --- gcc/gcc/cp/parser.c +++ gcc/gcc/cp/parser.c @@ -12977,6 +12978,7 @@ cp_parser_storage_class_specifier_opt (cp_parser* parser) if (cxx_dialect != cxx98) return NULL_TREE; /* Fall through for C++98. */ + gcc_fallthrough (); case RID_REGISTER: case RID_STATIC: @@ -27250,6 +27253,7 @@ cp_parser_skip_to_end_of_template_parameter_list (cp_parser* parser) } /* Fall through for C++0x, so we handle the second `>' in the `>>'. */ + gcc_fallthrough (); case CPP_GREATER: if (!nesting_depth && level-- == 0) @@ -27705,6 +27709,7 @@ cp_parser_cache_defarg (cp_parser *parser, bool nsdmi) /* Fall through for C++0x, which treats the `>>' operator like two `>' tokens in certain cases. */ + gcc_fallthrough (); case CPP_GREATER: if (depth == 0) @@ -33347,6 +33352,7 @@ cp_parser_omp_for_cond (cp_parser *parser, tree decl, enum tree_code code) if (code == CILK_SIMD || code == CILK_FOR) break; /* Fall through: OpenMP disallows NE_EXPR. */ + gcc_fallthrough (); default: return error_mark_node; } --- gcc/gcc/cp/semantics.c +++ gcc/gcc/cp/semantics.c @@ -8892,6 +8894,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p, break; } /* Fall through for fields that aren't bitfields. */ + gcc_fallthrough (); case FUNCTION_DECL: case VAR_DECL: --- gcc/gcc/cp/typeck.c +++ gcc/gcc/cp/typeck.c @@ -1306,6 +1306,7 @@ structural_comptypes (tree t1, tree t2, int strict) if (TYPE_REF_IS_RVALUE (t1) != TYPE_REF_IS_RVALUE (t2)) return false; /* fall through to checks for pointer types */ + gcc_fallthrough (); case POINTER_TYPE: if (TYPE_MODE (t1) != TYPE_MODE (t2) @@ -4265,6 +4266,7 @@ cp_build_binary_op (location_t location, } /* The pointer - int case is just like pointer + int; fall through. */ + gcc_fallthrough (); case PLUS_EXPR: if ((code0 == POINTER_TYPE || code1 == POINTER_TYPE) && (code0 == INTEGER_TYPE || code1 == INTEGER_TYPE)) @@ -7531,7 +7533,7 @@ cp_build_modify_expr (location_t loc, tree lhs, enum tree_code modifycode, TREE_OPERAND (lhs, 1)), TREE_OPERAND (lhs, 0), TREE_OPERAND (lhs, 1)); - /* Fall through. */ + gcc_fallthrough (); /* Handle (a ? b : c) used as an "lvalue". */ case COND_EXPR: --- gcc/gcc/final.c +++ gcc/gcc/final.c @@ -2096,9 +2096,11 @@ output_alternate_entry_point (FILE *file, rtx_insn *insn) case LABEL_WEAK_ENTRY: #ifdef ASM_WEAKEN_LABEL ASM_WEAKEN_LABEL (file, name); + gcc_fallthrough (); #endif case LABEL_GLOBAL_ENTRY: targetm.asm_out.globalize_label (file, name); + gcc_fallthrough (); case LABEL_STATIC_ENTRY: #ifdef ASM_OUTPUT_TYPE_DIRECTIVE ASM_OUTPUT_TYPE_DIRECTIVE (file, name, "function"); --- gcc/gcc/fortran/arith.c +++ gcc/gcc/fortran/arith.c @@ -1521,7 +1521,7 @@ eval_intrinsic (gfc_intrinsic_op op, break; } - /* Fall through */ + gcc_fallthrough (); /* Numeric binary */ case INTRINSIC_PLUS: case INTRINSIC_MINUS: --- gcc/gcc/fortran/frontend-passes.c +++ gcc/gcc/fortran/frontend-passes.c @@ -1452,7 +1452,7 @@ optimize_op (gfc_expr *e) case INTRINSIC_LT: changed = optimize_comparison (e, op); - /* Fall through */ + gcc_fallthrough (); /* Look at array constructors. */ case INTRINSIC_PLUS: case INTRINSIC_MINUS: @@ -3320,6 +3320,7 @@ gfc_expr_walker (gfc_expr **e, walk_expr_fn_t exprfn, void *data) /* Fall through to the variable case in order to walk the reference. */ + gcc_fallthrough (); case EXPR_SUBSTRING: case EXPR_VARIABLE: --- gcc/gcc/fortran/parse.c +++ gcc/gcc/fortran/parse.c @@ -1262,7 +1262,7 @@ next_fixed (void) return decode_oacc_directive (); } } - /* FALLTHROUGH */ + gcc_fallthrough (); /* Comments have already been skipped by the time we get here so don't bother checking for them. */ --- gcc/gcc/fortran/primary.c +++ gcc/gcc/fortran/primary.c @@ -3412,6 +3415,7 @@ match_variable (gfc_expr **result, int equiv_flag, int host_flag) break; /* Fall through to error */ + gcc_fallthrough (); default: gfc_error ("%qs at %C is not a variable", sym->name); --- gcc/gcc/fortran/trans-array.c +++ gcc/gcc/fortran/trans-array.c @@ -4031,6 +4031,7 @@ done: continue; } /* Otherwise fall through GFC_SS_FUNCTION. */ + gcc_fallthrough (); } case GFC_ISYM_LCOBOUND: case GFC_ISYM_UCOBOUND: --- gcc/gcc/fortran/trans-expr.c +++ gcc/gcc/fortran/trans-expr.c @@ -2102,6 +2102,7 @@ flatten_array_ctors_without_strlen (gfc_expr* e) } /* Otherwise, fall through to handle constructor elements. */ + gcc_fallthrough (); case EXPR_STRUCTURE: for (c = gfc_constructor_first (e->value.constructor); c; c = gfc_constructor_next (c)) --- gcc/gcc/genattrtab.c +++ gcc/gcc/genattrtab.c @@ -1218,6 +1219,7 @@ make_canonical (file_location loc, struct attr_desc *attr, rtx exp) exp = newexp; /* Fall through to COND case since this is now a COND. */ + gcc_fallthrough (); case COND: { @@ -3613,6 +3616,7 @@ write_test_expr (FILE *outf, rtx exp, unsigned int attrs_cached, int flags, } /* Otherwise, fall through to normal unary operator. */ + gcc_fallthrough (); /* Unary operators. */ case ABS: case NEG: --- gcc/gcc/genpreds.c +++ gcc/gcc/genpreds.c @@ -74,7 +74,7 @@ validate_exp (rtx exp, const char *name, file_location loc) } } } - /* fall through */ + gcc_fallthrough (); /* These need no special checking. */ case MATCH_OPERAND: --- gcc/gcc/gimple-ssa-strength-reduction.c +++ gcc/gcc/gimple-ssa-strength-reduction.c @@ -1690,7 +1690,7 @@ find_candidates_dom_walker::before_dom_children (basic_block bb) case POINTER_PLUS_EXPR: case MINUS_EXPR: rhs2 = gimple_assign_rhs2 (gs); - /* Fall-through. */ + gcc_fallthrough (); CASE_CONVERT: case MODIFY_EXPR: --- gcc/gcc/godump.c +++ gcc/gcc/godump.c @@ -893,6 +893,7 @@ go_format_type (struct godump_container *container, tree type, case UNION_TYPE: is_union = true; /* Fall through to RECORD_TYPE case. */ + gcc_fallthrough (); case RECORD_TYPE: { unsigned int prev_field_end; --- gcc/gcc/reload1.c +++ gcc/gcc/reload1.c @@ -3030,6 +3030,7 @@ elimination_effects (rtx x, machine_mode mem_mode) break; /* Fall through to generic unary operation case. */ + gcc_fallthrough (); case STRICT_LOW_PART: case NEG: case NOT: case SIGN_EXTEND: case ZERO_EXTEND: --- gcc/gcc/resource.c +++ gcc/gcc/resource.c @@ -364,6 +364,7 @@ mark_referenced_resources (rtx x, struct resources *res, } /* ... fall through to other INSN processing ... */ + gcc_fallthrough (); case INSN: case JUMP_INSN: @@ -674,6 +675,7 @@ mark_set_resources (rtx x, struct resources *res, int in_dest, } /* ... and also what its RTL says it modifies, if anything. */ + gcc_fallthrough (); case JUMP_INSN: case INSN: --- gcc/gcc/tree-ssa-loop-ivopts.c +++ gcc/gcc/tree-ssa-loop-ivopts.c @@ -1885,8 +1885,8 @@ find_deriving_biv_for_expr (struct ivopts_data *data, tree expr) iv = find_deriving_biv_for_expr (data, e2); if (iv) return iv; + gcc_fallthrough (); - /* Fallthru. */ CASE_CONVERT: /* Casts are simple. */ return find_deriving_biv_for_expr (data, e1); --- gcc/gcc/varasm.c +++ gcc/gcc/varasm.c @@ -4172,7 +4173,7 @@ output_addressed_constants (tree exp) case POINTER_PLUS_EXPR: case MINUS_EXPR: output_addressed_constants (TREE_OPERAND (exp, 1)); - /* Fall through. */ + gcc_fallthrough (); CASE_CONVERT: case VIEW_CONVERT_EXPR: --- gcc/libstdc++-v3/libsupc++/hash_bytes.cc +++ gcc/libstdc++-v3/libsupc++/hash_bytes.cc @@ -95,8 +95,10 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { case 3: hash ^= static_cast<unsigned char>(buf[2]) << 16; + [[gnu::fallthrough]]; case 2: hash ^= static_cast<unsigned char>(buf[1]) << 8; + [[gnu::fallthrough]]; case 1: hash ^= static_cast<unsigned char>(buf[0]); hash *= m; Marek