Implement -Wswitch-fallthrough: fortran/
Marek Polacek
polacek@redhat.com
Mon Jul 11 19:52:00 GMT 2016
2016-07-11 Marek Polacek <polacek@redhat.com>
PR c/7652
* arith.c (eval_intrinsic): Add gcc_fallthrough.
* array.c (gfc_ref_dimen_size): Likewise.
(gfc_array_dimen_size): Likewise.
* cpp.c (gfc_cpp_handle_option): Likewise.
(cb_cpp_error): Likewise.
* decl.c (match_implicit_range): Likewise.
(match_attr_spec): Likewise.
* dependency.c (gfc_dep_resolver): Likewise.
* dump-parse-tree.c (show_code_node): Likewise.
* expr.c (simplify_const_ref): Likewise.
* frontend-passes.c (optimize_op): Likewise.
(gfc_expr_walker): Likewise.
(gfc_code_walker): Likewise.
* gfortranspec.c: Likewise.
* interface.c (gfc_check_operator_interface): Likewise.
* io.c (format_lex): Likewise.
* openmp.c (resolve_omp_clauses): Likewise.
* parse.c (next_fixed): Likewise.
(parse_select_block): Likewise.
(parse_select_type_block): Likewise.
(parse_executable): Likewise.
* primary.c (match_boz_constant): Likewise.
(match_arg_list_function): Likewise.
(gfc_match_rvalue): Likewise.
(match_variable): Likewise.
* resolve.c (resolve_operator): Likewise.
(resolve_ref): Likewise.
(fixup_charlen): Likewise.
(resolve_allocate_expr): Likewise.
(gfc_resolve_code): Likewise.
(build_default_init_expr): Likewise.
* target-memory.c (gfc_target_interpret_expr): Likewise.
* trans-array.c (gfc_array_allocate): Likewise.
* trans-expr.c (flatten_array_ctors_without_strlen): Likewise.
(gfc_conv_power_op): Likewise.
(gfc_conv_expr_op): Likewise.
* trans-intrinsic.c (conv_caf_vector_subscript): Likewise.
(conv_intrinsic_cobound): Likewise.
(gfc_conv_intrinsic_len): Likewise.
* trans-io.c (gfc_build_st_parameter): Likewise.
(transfer_expr): Likewise.
* trans-stmt.c (gfc_trans_where_2): Likewise.
diff --git gcc/gcc/fortran/arith.c gcc/gcc/fortran/arith.c
index 47a5504..a56b480 100644
--- gcc/gcc/fortran/arith.c
+++ gcc/gcc/fortran/arith.c
@@ -1504,6 +1504,7 @@ eval_intrinsic (gfc_intrinsic_op op,
}
/* Fall through */
+ gcc_fallthrough ();
case INTRINSIC_EQ:
case INTRINSIC_EQ_OS:
case INTRINSIC_NE:
@@ -1523,6 +1524,7 @@ eval_intrinsic (gfc_intrinsic_op op,
/* Fall through */
/* Numeric binary */
+ gcc_fallthrough ();
case INTRINSIC_PLUS:
case INTRINSIC_MINUS:
case INTRINSIC_TIMES:
diff --git gcc/gcc/fortran/array.c gcc/gcc/fortran/array.c
index 03c8b17..d020709 100644
--- gcc/gcc/fortran/array.c
+++ gcc/gcc/fortran/array.c
@@ -2323,6 +2323,7 @@ gfc_ref_dimen_size (gfc_array_ref *ar, int dimen, mpz_t *result, mpz_t *end)
mpz_mul (*end, *end, stride);
mpz_add (*end, *end, lower);
}
+ gcc_fallthrough ();
cleanup:
mpz_clear (upper);
@@ -2432,6 +2433,7 @@ gfc_array_dimen_size (gfc_expr *array, int dimen, mpz_t *result)
}
/* Fall through */
+ gcc_fallthrough ();
default:
if (array->shape == NULL)
return false;
diff --git gcc/gcc/fortran/cpp.c gcc/gcc/fortran/cpp.c
index 8ac8092..df81cbc 100644
--- gcc/gcc/fortran/cpp.c
+++ gcc/gcc/fortran/cpp.c
@@ -390,6 +390,7 @@ gfc_cpp_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED
case OPT_MM:
gfc_cpp_option.deps_skip_system = 1;
/* fall through */
+ gcc_fallthrough ();
case OPT_M:
gfc_cpp_option.deps = 1;
@@ -398,6 +399,7 @@ gfc_cpp_handle_option (size_t scode, const char *arg, int value ATTRIBUTE_UNUSED
case OPT_MMD:
gfc_cpp_option.deps_skip_system = 1;
/* fall through */
+ gcc_fallthrough ();
case OPT_MD:
gfc_cpp_option.deps = 1;
@@ -1037,6 +1039,7 @@ cb_cpp_error (cpp_reader *pfile ATTRIBUTE_UNUSED, int level, int reason,
case CPP_DL_WARNING_SYSHDR:
global_dc->dc_warn_system_headers = 1;
/* Fall through. */
+ gcc_fallthrough ();
case CPP_DL_WARNING:
dlevel = DK_WARNING;
break;
diff --git gcc/gcc/fortran/decl.c gcc/gcc/fortran/decl.c
index 1b62833..3d6b7e4 100644
--- gcc/gcc/fortran/decl.c
+++ gcc/gcc/fortran/decl.c
@@ -3486,6 +3486,7 @@ match_implicit_range (void)
{
case ')':
inner = 0; /* Fall through. */
+ gcc_fallthrough ();
case ',':
c2 = c1;
@@ -3911,6 +3912,7 @@ match_attr_spec (void)
d = DECL_CODIMENSION;
break;
}
+ gcc_fallthrough ();
case 'n':
if (match_string_p ("tiguous"))
{
diff --git gcc/gcc/fortran/dependency.c gcc/gcc/fortran/dependency.c
index f117de0..207825e 100644
--- gcc/gcc/fortran/dependency.c
+++ gcc/gcc/fortran/dependency.c
@@ -2199,6 +2199,7 @@ gfc_dep_resolver (gfc_ref *lref, gfc_ref *rref, gfc_reverse *reverse)
/* Overlap codes are in order of priority. We only need to
know the worst one.*/
+ gcc_fallthrough ();
update_fin_dep:
if (this_dep > fin_dep)
diff --git gcc/gcc/fortran/dump-parse-tree.c gcc/gcc/fortran/dump-parse-tree.c
index f507434..1170948 100644
--- gcc/gcc/fortran/dump-parse-tree.c
+++ gcc/gcc/fortran/dump-parse-tree.c
@@ -1617,6 +1617,7 @@ show_code_node (int level, gfc_code *c)
case EXEC_ERROR_STOP:
fputs ("ERROR ", dumpfile);
/* Fall through. */
+ gcc_fallthrough ();
case EXEC_STOP:
fputs ("STOP ", dumpfile);
@@ -2162,6 +2163,7 @@ show_code_node (int level, gfc_code *c)
case EXEC_FLUSH:
fputs ("FLUSH", dumpfile);
+ gcc_fallthrough ();
show_filepos:
fp = c->ext.filepos;
@@ -2378,6 +2380,7 @@ show_code_node (int level, gfc_code *c)
case EXEC_WRITE:
fputs ("WRITE", dumpfile);
+ gcc_fallthrough ();
show_dt:
dt = c->ext.dt;
@@ -2468,6 +2471,7 @@ show_code_node (int level, gfc_code *c)
fputs (" SIGN=", dumpfile);
show_expr (dt->sign);
}
+ gcc_fallthrough ();
show_dt_code:
for (c = c->block->next; c; c = c->next)
diff --git gcc/gcc/fortran/expr.c gcc/gcc/fortran/expr.c
index 7328898..8557ff7 100644
--- gcc/gcc/fortran/expr.c
+++ gcc/gcc/fortran/expr.c
@@ -1646,6 +1646,7 @@ simplify_const_ref (gfc_expr *p)
p->ref->u.ar.type = AR_FULL;
/* Fall through. */
+ gcc_fallthrough ();
case AR_FULL:
if (p->ref->next != NULL
diff --git gcc/gcc/fortran/frontend-passes.c gcc/gcc/fortran/frontend-passes.c
index f02a52a..652ec89 100644
--- gcc/gcc/fortran/frontend-passes.c
+++ gcc/gcc/fortran/frontend-passes.c
@@ -1445,6 +1445,7 @@ optimize_op (gfc_expr *e)
changed = optimize_comparison (e, op);
/* Fall through */
+ gcc_fallthrough ();
/* Look at array constructors. */
case INTRINSIC_PLUS:
case INTRINSIC_MINUS:
@@ -3312,6 +3313,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:
@@ -3345,6 +3347,7 @@ gfc_expr_walker (gfc_expr **e, walk_expr_fn_t exprfn, void *data)
break;
}
}
+ gcc_fallthrough ();
default:
break;
@@ -3600,6 +3603,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t codefn, walk_expr_fn_t exprfn,
in_omp_workshare = true;
/* Fall through */
+ gcc_fallthrough ();
case EXEC_OMP_DISTRIBUTE:
case EXEC_OMP_DISTRIBUTE_PARALLEL_DO:
diff --git gcc/gcc/fortran/gfortranspec.c gcc/gcc/fortran/gfortranspec.c
index 8a0e19a..a09b167 100644
--- gcc/gcc/fortran/gfortranspec.c
+++ gcc/gcc/fortran/gfortranspec.c
@@ -395,10 +395,12 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"
case 0:
add_arg_libgfortran (static_lib && !static_linking);
/* Fall through. */
+ gcc_fallthrough ();
case 1:
if (need_math)
append_option (OPT_l, MATH_LIBRARY, 1);
+ gcc_fallthrough ();
default:
break;
}
diff --git gcc/gcc/fortran/interface.c gcc/gcc/fortran/interface.c
index 5bd1279..736112c 100644
--- gcc/gcc/fortran/interface.c
+++ gcc/gcc/fortran/interface.c
@@ -930,6 +930,7 @@ gfc_check_operator_interface (gfc_symbol *sym, gfc_intrinsic_op op,
if (t1 == BT_CHARACTER && t2 == BT_CHARACTER)
goto bad_repl;
/* Fall through. */
+ gcc_fallthrough ();
case INTRINSIC_PLUS:
case INTRINSIC_MINUS:
diff --git gcc/gcc/fortran/io.c gcc/gcc/fortran/io.c
index 7c648e9..7b6f00f 100644
--- gcc/gcc/fortran/io.c
+++ gcc/gcc/fortran/io.c
@@ -242,6 +242,7 @@ format_lex (void)
case '-':
negative_flag = 1;
/* Falls through. */
+ gcc_fallthrough ();
case '+':
c = next_char_not_space (&error);
diff --git gcc/gcc/fortran/openmp.c gcc/gcc/fortran/openmp.c
index 865e0d9..cb08879 100644
--- gcc/gcc/fortran/openmp.c
+++ gcc/gcc/fortran/openmp.c
@@ -3762,6 +3762,7 @@ resolve_omp_clauses (gfc_code *code, gfc_omp_clauses *omp_clauses,
gfc_error ("Cray pointee object %qs in %s clause at %L",
n->sym->name, name, &n->where);
/* FALLTHRU */
+ gcc_fallthrough ();
case OMP_LIST_DEVICE_RESIDENT:
check_symbol_not_pointer (n->sym, n->where, name);
check_array_not_assumed (n->sym, n->where, name);
diff --git gcc/gcc/fortran/parse.c gcc/gcc/fortran/parse.c
index d795225..65e7b8d 100644
--- gcc/gcc/fortran/parse.c
+++ gcc/gcc/fortran/parse.c
@@ -1235,6 +1235,7 @@ next_fixed (void)
}
}
/* FALLTHROUGH */
+ gcc_fallthrough ();
/* Comments have already been skipped by the time we get
here so don't bother checking for them. */
@@ -3609,6 +3610,7 @@ loop:
break;
/* Fall through */
+ gcc_fallthrough ();
case ST_USE:
case ST_IMPORT:
@@ -3672,6 +3674,7 @@ declSt:
break;
}
+ gcc_fallthrough ();
default:
break;
}
@@ -4007,6 +4010,7 @@ parse_select_block (void)
accept_statement (st);
/* Fall through */
+ gcc_fallthrough ();
case ST_END_SELECT:
break;
@@ -4091,6 +4095,7 @@ parse_select_type_block (void)
accept_statement (st);
/* Fall through */
+ gcc_fallthrough ();
case ST_END_SELECT:
break;
@@ -5103,6 +5108,7 @@ parse_executable (gfc_statement st)
gfc_notify_std (GFC_STD_F95_OBS, "DATA statement at %C after the "
"first executable statement");
/* Fall through. */
+ gcc_fallthrough ();
case ST_FORMAT:
case ST_ENTRY:
diff --git gcc/gcc/fortran/primary.c gcc/gcc/fortran/primary.c
index c2faa0f..141cd86 100644
--- gcc/gcc/fortran/primary.c
+++ gcc/gcc/fortran/primary.c
@@ -366,12 +366,14 @@ match_boz_constant (gfc_expr **result)
case 'x':
x_hex = 1;
/* Fall through. */
+ gcc_fallthrough ();
case 'z':
radix = 16;
post = 0;
break;
case '\'':
/* Fall through. */
+ gcc_fallthrough ();
case '\"':
delim = post;
post = 1;
@@ -1686,18 +1688,21 @@ match_arg_list_function (gfc_actual_arglist *result)
result->name = "%LOC";
break;
}
+ gcc_fallthrough ();
case 'r':
if (strncmp (name, "ref", 3) == 0)
{
result->name = "%REF";
break;
}
+ gcc_fallthrough ();
case 'v':
if (strncmp (name, "val", 3) == 0)
{
result->name = "%VAL";
break;
}
+ gcc_fallthrough ();
default:
m = MATCH_ERROR;
goto cleanup;
@@ -3007,6 +3012,7 @@ gfc_match_rvalue (gfc_expr **result)
m = gfc_match_varspec (e, 0, false, true);
break;
}
+ gcc_fallthrough ();
/* Match a function reference. */
function0:
@@ -3412,6 +3418,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);
diff --git gcc/gcc/fortran/resolve.c gcc/gcc/fortran/resolve.c
index 4378313..debcd9e 100644
--- gcc/gcc/fortran/resolve.c
+++ gcc/gcc/fortran/resolve.c
@@ -3543,6 +3543,7 @@ resolve_operator (gfc_expr *e)
return false;
/* Fall through... */
+ gcc_fallthrough ();
case INTRINSIC_NOT:
case INTRINSIC_UPLUS:
@@ -3661,6 +3662,7 @@ resolve_operator (gfc_expr *e)
}
/* Fall through... */
+ gcc_fallthrough ();
case INTRINSIC_EQ:
case INTRINSIC_EQ_OS:
@@ -4688,6 +4690,7 @@ resolve_ref (gfc_expr *expr)
break;
}
/* Fall through. */
+ gcc_fallthrough ();
case AR_SECTION:
current_part_dimension = 1;
break;
@@ -5419,14 +5422,17 @@ fixup_charlen (gfc_expr *e)
{
case EXPR_OP:
gfc_resolve_character_operator (e);
+ gcc_fallthrough ();
case EXPR_ARRAY:
if (e->expr_type == EXPR_ARRAY)
gfc_resolve_character_array_constructor (e);
+ gcc_fallthrough ();
case EXPR_SUBSTRING:
if (!e->ts.u.cl && e->ref)
gfc_resolve_substring_charlen (e);
+ gcc_fallthrough ();
default:
if (!e->ts.u.cl)
@@ -7279,6 +7285,7 @@ resolve_allocate_expr (gfc_expr *e, gfc_code *code, bool *array_alloc_wo_spec)
break;
/* Fall Through... */
+ gcc_fallthrough ();
case DIMEN_UNKNOWN:
case DIMEN_VECTOR:
@@ -10432,6 +10439,7 @@ gfc_resolve_code (gfc_code *code, gfc_namespace *ns)
omp_workshare_save = omp_workshare_flag;
omp_workshare_flag = 1;
/* FALL THROUGH */
+ gcc_fallthrough ();
default:
gfc_resolve_blocks (code->block, ns);
break;
@@ -11183,6 +11191,7 @@ build_default_init_expr (gfc_symbol *sym)
case GFC_INIT_REAL_SNAN:
init_expr->is_snan = 1;
/* Fall through. */
+ gcc_fallthrough ();
case GFC_INIT_REAL_NAN:
mpfr_set_nan (init_expr->value.real);
break;
@@ -11212,6 +11221,7 @@ build_default_init_expr (gfc_symbol *sym)
case GFC_INIT_REAL_SNAN:
init_expr->is_snan = 1;
/* Fall through. */
+ gcc_fallthrough ();
case GFC_INIT_REAL_NAN:
mpfr_set_nan (mpc_realref (init_expr->value.complex));
mpfr_set_nan (mpc_imagref (init_expr->value.complex));
diff --git gcc/gcc/fortran/target-memory.c gcc/gcc/fortran/target-memory.c
index 0c71c3c..ee1bd73 100644
--- gcc/gcc/fortran/target-memory.c
+++ gcc/gcc/fortran/target-memory.c
@@ -600,6 +600,7 @@ gfc_target_interpret_expr (unsigned char *buffer, size_t buffer_size,
case BT_CLASS:
result->ts = CLASS_DATA (result)->ts;
/* Fall through. */
+ gcc_fallthrough ();
case BT_DERIVED:
result->representation.length =
gfc_interpret_derived (buffer, buffer_size, result);
diff --git gcc/gcc/fortran/trans-array.c gcc/gcc/fortran/trans-array.c
index e95c8dd..81c523d 100644
--- 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:
@@ -4040,6 +4041,7 @@ done:
default:
continue;
}
+ gcc_fallthrough ();
case GFC_SS_CONSTRUCTOR:
case GFC_SS_FUNCTION:
@@ -5451,6 +5453,7 @@ gfc_array_allocate (gfc_se * se, gfc_expr * expr, tree status, tree errmsg,
break;
}
/* Fall through. */
+ gcc_fallthrough ();
case AR_SECTION:
lower = ref->u.ar.start;
diff --git gcc/gcc/fortran/trans-expr.c gcc/gcc/fortran/trans-expr.c
index b5731aa..54ad600 100644
--- 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))
@@ -2936,6 +2937,7 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr)
rse.expr = convert (gfc_int4_type_node, rse.expr);
res_ikind_2 = ikind;
/* Fall through. */
+ gcc_fallthrough ();
case 4:
ikind = 0;
@@ -2964,6 +2966,7 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr)
else
gcc_unreachable ();
/* Fall through. */
+ gcc_fallthrough ();
case 4:
kind = 0;
@@ -3202,6 +3205,7 @@ gfc_conv_expr_op (gfc_se * se, gfc_expr * expr)
}
/* Fallthrough. */
+ gcc_fallthrough ();
case INTRINSIC_UPLUS:
gfc_conv_expr (se, expr->value.op.op1);
return;
diff --git gcc/gcc/fortran/trans-intrinsic.c gcc/gcc/fortran/trans-intrinsic.c
index c655540..9d20be3 100644
--- gcc/gcc/fortran/trans-intrinsic.c
+++ gcc/gcc/fortran/trans-intrinsic.c
@@ -1047,6 +1047,7 @@ conv_caf_vector_subscript (stmtblock_t *block, tree desc, gfc_array_ref *ar)
stride = gfc_index_one_node;
/* Fall through. */
+ gcc_fallthrough ();
case DIMEN_ELEMENT:
if (ar->start[i])
{
@@ -2136,6 +2137,7 @@ conv_intrinsic_cobound (gfc_se * se, gfc_expr * expr)
bound = fold_build2_loc (input_location, MINUS_EXPR,
gfc_array_index_type, bound,
gfc_index_one_node);
+ gcc_fallthrough ();
case 1:
break;
default:
@@ -5330,6 +5332,7 @@ gfc_conv_intrinsic_len (gfc_se * se, gfc_expr * expr)
}
/* Otherwise fall through. */
+ gcc_fallthrough ();
default:
/* Anybody stupid enough to do this deserves inefficient code. */
diff --git gcc/gcc/fortran/trans-io.c gcc/gcc/fortran/trans-io.c
index aefa96d..829db5d 100644
--- gcc/gcc/fortran/trans-io.c
+++ gcc/gcc/fortran/trans-io.c
@@ -194,6 +194,7 @@ gfc_build_st_parameter (enum ioparam_type ptype, tree *types)
p->field = gfc_add_field_to_struct (t, get_identifier (p->name),
pchar_type_node, &chain);
/* FALLTHROUGH */
+ gcc_fallthrough ();
case IOPARM_type_char2:
len = strlen (p->name);
gcc_assert (len <= sizeof (name) - sizeof ("_len"));
@@ -2194,6 +2195,7 @@ transfer_expr (gfc_se * se, gfc_typespec * ts, tree addr_expr, gfc_code * code)
return;
}
/* Fall through. */
+ gcc_fallthrough ();
case BT_HOLLERITH:
if (se->string_length)
arg2 = se->string_length;
diff --git gcc/gcc/fortran/trans-stmt.c gcc/gcc/fortran/trans-stmt.c
index 5aa7778..8d527ed 100644
--- gcc/gcc/fortran/trans-stmt.c
+++ gcc/gcc/fortran/trans-stmt.c
@@ -4962,6 +4962,7 @@ gfc_trans_where_2 (gfc_code * code, tree mask, bool invert,
case EXEC_ASSIGN:
expr1 = cnext->expr1;
expr2 = cnext->expr2;
+ gcc_fallthrough ();
evaluate:
if (nested_forall_info != NULL)
{
More information about the Gcc-patches
mailing list