* [RFA 1/3] Fix "fall through" comments
2016-09-27 18:16 [RFA 0/3] Fix some -Wimplicit-fallthrough warnings Tom Tromey
2016-09-27 18:16 ` [RFA 2/3] Add missing ATTRIBUTE_NORETURNs Tom Tromey
@ 2016-09-27 18:16 ` Tom Tromey
2016-09-27 21:48 ` Yao Qi
2016-09-27 18:52 ` [RFA 3/3] Fix "obvious" fall-through warnings Tom Tromey
2 siblings, 1 reply; 12+ messages in thread
From: Tom Tromey @ 2016-09-27 18:16 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This patch updates existing "fall through" comments so that they can
be recognized by gcc's -Wimplicit-fallthrough comment-parsing
heuristic.
2016-09-27 Tom Tromey <tom@tromey.com>
* xcoffread.c (scan_xcoff_symtab): Move comment later.
* symfile.c (section_is_mapped): Fix fall-through comment.
* stabsread.c (define_symbol, read_member_functions): Fix
fall-through comment.
* s390-linux-tdep.c (s390_process_record): Fix fall-through
comment.
* remote.c (remote_wait_as): Fix fall-through comment.
* p-exp.y (yylex): Fix fall-through comment.
* nat/x86-dregs.c (x86_length_and_rw_bits): Fix fall-through
comment.
* msp430-tdep.c (msp430_gdbarch_init): Fix fall-through comment.
* mdebugread.c (parse_partial_symbols): Fix fall-through comment.
* jv-exp.y (yylex): Fix fall-through comment.
* go-exp.y (lex_one_token): Fix fall-through comment.
* gdbtypes.c (get_discrete_bounds, rank_one_type): Fix
fall-through comment.
* f-exp.y (yylex): Fix fall-through comment.
* dwarf2read.c (process_die): Fix fall-through comment.
* dbxread.c (process_one_symbol): Fix fall-through comment.
* d-exp.y (lex_one_token): Fix fall-through comment.
* cp-name-parser.y (yylex): Fix fall-through comment.
* coffread.c (coff_symtab_read): Fix fall-through comment.
* c-exp.y (lex_one_token): Fix fall-through comment.
* arm-tdep.c (arm_decode_miscellaneous): Fix fall-through
comment.
* arch/arm.c (arm_instruction_changes_pc): Fix fall-through
comment.
---
gdb/ChangeLog | 30 ++++++++++++++++++++++++++++++
gdb/arch/arm.c | 3 ++-
gdb/arm-tdep.c | 1 +
gdb/c-exp.y | 2 +-
gdb/coffread.c | 3 ++-
gdb/cp-name-parser.y | 2 +-
gdb/d-exp.y | 2 +-
gdb/dbxread.c | 4 ++--
gdb/dwarf2read.c | 3 ++-
gdb/f-exp.y | 2 +-
gdb/gdbtypes.c | 6 +++---
gdb/go-exp.y | 2 +-
gdb/jv-exp.y | 2 +-
gdb/mdebugread.c | 3 ++-
gdb/msp430-tdep.c | 2 +-
gdb/nat/x86-dregs.c | 2 +-
gdb/p-exp.y | 2 +-
gdb/remote.c | 2 +-
gdb/s390-linux-tdep.c | 5 +++--
gdb/stabsread.c | 5 +++--
gdb/symfile.c | 2 +-
gdb/xcoffread.c | 2 +-
22 files changed, 62 insertions(+), 25 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 4810f1b..fdd43ab 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,33 @@
+2016-09-27 Tom Tromey <tom@tromey.com>
+
+ * xcoffread.c (scan_xcoff_symtab): Move comment later.
+ * symfile.c (section_is_mapped): Fix fall-through comment.
+ * stabsread.c (define_symbol, read_member_functions): Fix
+ fall-through comment.
+ * s390-linux-tdep.c (s390_process_record): Fix fall-through
+ comment.
+ * remote.c (remote_wait_as): Fix fall-through comment.
+ * p-exp.y (yylex): Fix fall-through comment.
+ * nat/x86-dregs.c (x86_length_and_rw_bits): Fix fall-through
+ comment.
+ * msp430-tdep.c (msp430_gdbarch_init): Fix fall-through comment.
+ * mdebugread.c (parse_partial_symbols): Fix fall-through comment.
+ * jv-exp.y (yylex): Fix fall-through comment.
+ * go-exp.y (lex_one_token): Fix fall-through comment.
+ * gdbtypes.c (get_discrete_bounds, rank_one_type): Fix
+ fall-through comment.
+ * f-exp.y (yylex): Fix fall-through comment.
+ * dwarf2read.c (process_die): Fix fall-through comment.
+ * dbxread.c (process_one_symbol): Fix fall-through comment.
+ * d-exp.y (lex_one_token): Fix fall-through comment.
+ * cp-name-parser.y (yylex): Fix fall-through comment.
+ * coffread.c (coff_symtab_read): Fix fall-through comment.
+ * c-exp.y (lex_one_token): Fix fall-through comment.
+ * arm-tdep.c (arm_decode_miscellaneous): Fix fall-through
+ comment.
+ * arch/arm.c (arm_instruction_changes_pc): Fix fall-through
+ comment.
+
2016-09-27 Fredrik Hederstierna <fredrik.hederstierna@verisure.com>
* arm-tdep.c (arm_m_addr_is_magic): New function.
diff --git a/gdb/arch/arm.c b/gdb/arch/arm.c
index b6770fe..03ed7c4 100644
--- a/gdb/arch/arm.c
+++ b/gdb/arch/arm.c
@@ -153,7 +153,8 @@ arm_instruction_changes_pc (uint32_t this_instr)
modify PC. */
return 0;
}
- /* Data processing instruction. Fall through. */
+ /* Data processing instruction. */
+ /* Fall through. */
case 0x1:
if (bits (this_instr, 12, 15) == 15)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index a07d93b..3fc5e40 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -6655,6 +6655,7 @@ arm_decode_miscellaneous (struct gdbarch *gdbarch, uint32_t insn,
else if (op == 0x3)
/* Not really supported. */
return arm_copy_unmodified (gdbarch, insn, "smc", dsc);
+ /* Fall through. */
default:
return arm_copy_undef (gdbarch, insn, dsc);
diff --git a/gdb/c-exp.y b/gdb/c-exp.y
index 29f672f..73589d4 100644
--- a/gdb/c-exp.y
+++ b/gdb/c-exp.y
@@ -2527,7 +2527,7 @@ lex_one_token (struct parser_state *par_state, int *is_quoted_name)
last_was_structop = 1;
goto symbol; /* Nope, must be a symbol. */
}
- /* FALL THRU into number case. */
+ /* FALL THRU. */
case '0':
case '1':
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 830deb5..49d6803 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -968,7 +968,8 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
/* At least on a 3b1, gcc generates swbeg and string labels
that look like this. Ignore them. */
break;
- /* Fall in for static symbols that don't start with '.' */
+ /* For static symbols that don't start with '.'... */
+ /* Fall through. */
case C_THUMBEXT:
case C_THUMBEXTFUNC:
case C_EXT:
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index c6a5c34..e15b0f6 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -1673,7 +1673,7 @@ yylex (void)
lexptr++;
return '-';
}
- /* FALL THRU into number case. */
+ /* FALL THRU. */
try_number:
case '0':
diff --git a/gdb/d-exp.y b/gdb/d-exp.y
index 426f9b3..a3287e6 100644
--- a/gdb/d-exp.y
+++ b/gdb/d-exp.y
@@ -1123,7 +1123,7 @@ lex_one_token (struct parser_state *par_state)
last_was_structop = 1;
goto symbol; /* Nope, must be a symbol. */
}
- /* FALL THRU into number case. */
+ /* FALL THRU. */
case '0':
case '1':
diff --git a/gdb/dbxread.c b/gdb/dbxread.c
index d5a9587..bef28db 100644
--- a/gdb/dbxread.c
+++ b/gdb/dbxread.c
@@ -3069,9 +3069,9 @@ process_one_symbol (int type, int desc, CORE_ADDR valu, char *name,
unknown_symtype_complaint (hex_string (type));
/* FALLTHROUGH */
- /* The following symbol types don't need the address field
- relocated, since it is either unused, or is absolute. */
define_a_symbol:
+ /* These symbol types don't need the address field relocated,
+ since it is either unused, or is absolute. */
case N_GSYM: /* Global variable. */
case N_NSYMS: /* Number of symbols (Ultrix). */
case N_NOMAP: /* No map? (Ultrix). */
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index d0f6e71..42b5704 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8339,7 +8339,8 @@ process_die (struct die_info *die, struct dwarf2_cu *cu)
cu->processing_has_namespace_info = 1;
if (read_namespace_alias (die, cu))
break;
- /* The declaration is not a global namespace alias: fall through. */
+ /* The declaration is not a global namespace alias. */
+ /* fall through. */
case DW_TAG_imported_module:
cu->processing_has_namespace_info = 1;
if (die->child != NULL && (die->tag == DW_TAG_imported_declaration
diff --git a/gdb/f-exp.y b/gdb/f-exp.y
index 420f18e..fecfdc9 100644
--- a/gdb/f-exp.y
+++ b/gdb/f-exp.y
@@ -1006,7 +1006,7 @@ yylex (void)
/* Might be a floating point number. */
if (lexptr[1] < '0' || lexptr[1] > '9')
goto symbol; /* Nope, must be a symbol. */
- /* FALL THRU into number case. */
+ /* FALL THRU. */
case '0':
case '1':
diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c
index ad890ca..d2a0f37 100644
--- a/gdb/gdbtypes.c
+++ b/gdb/gdbtypes.c
@@ -958,7 +958,7 @@ get_discrete_bounds (struct type *type, LONGEST *lowp, LONGEST *highp)
*highp = -*lowp - 1;
return 0;
}
- /* ... fall through for unsigned ints ... */
+ /* fall through */
case TYPE_CODE_CHAR:
*lowp = 0;
/* This round-about calculation is to avoid shifting by
@@ -3803,7 +3803,7 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value)
return INTEGER_CONVERSION_BADNESS;
else if (TYPE_LENGTH (arg) < TYPE_LENGTH (parm))
return INTEGER_PROMOTION_BADNESS;
- /* >>> !! else fall through !! <<< */
+ /* fall through */
case TYPE_CODE_CHAR:
/* Deal with signed, unsigned, and plain chars for C++ and
with int cases falling through from previous case. */
@@ -3909,7 +3909,7 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value)
rank.subrank = distance_to_ancestor (parm, arg, 0);
if (rank.subrank >= 0)
return sum_ranks (BASE_CONVERSION_BADNESS, rank);
- /* else fall through */
+ /* fall through */
default:
return INCOMPATIBLE_TYPE_BADNESS;
}
diff --git a/gdb/go-exp.y b/gdb/go-exp.y
index 1b0fe5b..2723789 100644
--- a/gdb/go-exp.y
+++ b/gdb/go-exp.y
@@ -1089,7 +1089,7 @@ lex_one_token (struct parser_state *par_state)
last_was_structop = 1;
goto symbol; /* Nope, must be a symbol. */
}
- /* FALL THRU into number case. */
+ /* FALL THRU. */
case '0':
case '1':
diff --git a/gdb/jv-exp.y b/gdb/jv-exp.y
index 79b8127..f9db49a 100644
--- a/gdb/jv-exp.y
+++ b/gdb/jv-exp.y
@@ -921,7 +921,7 @@ yylex (void)
/* Might be a floating point number. */
if (lexptr[1] < '0' || lexptr[1] > '9')
goto symbol; /* Nope, must be a symbol. */
- /* FALL THRU into number case. */
+ /* FALL THRU. */
case '0':
case '1':
diff --git a/gdb/mdebugread.c b/gdb/mdebugread.c
index 157ce77..9995659 100644
--- a/gdb/mdebugread.c
+++ b/gdb/mdebugread.c
@@ -3701,7 +3701,8 @@ parse_partial_symbols (struct objfile *objfile)
break;
default:
unknown_ext_complaint (debug_info->ssext + psh->iss);
- /* Fall through, pretend it's global. */
+ /* Pretend it's global. */
+ /* Fall through. */
case stGlobal:
/* Global common symbols are resolved by the runtime loader,
ignore them. */
diff --git a/gdb/msp430-tdep.c b/gdb/msp430-tdep.c
index 84189dc..bb03fec 100644
--- a/gdb/msp430-tdep.c
+++ b/gdb/msp430-tdep.c
@@ -923,8 +923,8 @@ msp430_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
code_model = ca_tdep->code_model;
break;
}
- /* Otherwise, fall through... */
}
+ /* Fall through. */
default:
error (_("Unknown msp430 isa"));
break;
diff --git a/gdb/nat/x86-dregs.c b/gdb/nat/x86-dregs.c
index 8403ca7..cb68866 100644
--- a/gdb/nat/x86-dregs.c
+++ b/gdb/nat/x86-dregs.c
@@ -257,7 +257,7 @@ Invalid hardware breakpoint type %d in x86_length_and_rw_bits.\n"),
case 8:
if (TARGET_HAS_DR_LEN_8)
return (DR_LEN_8 | rw);
- /* ELSE FALL THROUGH */
+ /* FALL THROUGH */
default:
internal_error (__FILE__, __LINE__, _("\
Invalid hardware breakpoint length %d in x86_length_and_rw_bits.\n"), len);
diff --git a/gdb/p-exp.y b/gdb/p-exp.y
index fa6b22c..e8612ee 100644
--- a/gdb/p-exp.y
+++ b/gdb/p-exp.y
@@ -1211,7 +1211,7 @@ yylex (void)
goto symbol; /* Nope, must be a symbol. */
}
- /* FALL THRU into number case. */
+ /* FALL THRU. */
case '0':
case '1':
diff --git a/gdb/remote.c b/gdb/remote.c
index ec8b498..d7266db 100644
--- a/gdb/remote.c
+++ b/gdb/remote.c
@@ -6984,7 +6984,7 @@ remote_wait_as (ptid_t ptid, struct target_waitstatus *status, int options)
putpkt (buf);
break;
}
- /* else fallthrough */
+ /* fallthrough */
default:
warning (_("Invalid remote reply: %s"), buf);
break;
diff --git a/gdb/s390-linux-tdep.c b/gdb/s390-linux-tdep.c
index 399084a..0b73b2d 100644
--- a/gdb/s390-linux-tdep.c
+++ b/gdb/s390-linux-tdep.c
@@ -5206,7 +5206,7 @@ ex:
return -1;
break;
}
- /* For other instructions, fallthru. */
+ /* fallthru. */
default:
fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KM* function %02x at %s.\n",
(int)tmp, paddress (gdbarch, addr));
@@ -5499,7 +5499,8 @@ ex:
return -1;
break;
}
- /* For KLMD, fallthru. */
+ /* For KLMD... */
+ /* fallthru. */
default:
fprintf_unfiltered (gdb_stdlog, "Warning: Unknown KMAC function %02x at %s.\n",
(int)tmp, paddress (gdbarch, addr));
diff --git a/gdb/stabsread.c b/gdb/stabsread.c
index e8ebadd..c3b9531 100644
--- a/gdb/stabsread.c
+++ b/gdb/stabsread.c
@@ -722,7 +722,7 @@ define_symbol (CORE_ADDR valu, char *string, int desc, int type,
/* SunPRO (3.0 at least) static variable encoding. */
if (gdbarch_static_transform_name_p (gdbarch))
goto normal;
- /* ... fall through ... */
+ /* fall through */
default:
complaint (&symfile_complaints, _("Unknown C++ symbol name `%s'"),
@@ -2530,7 +2530,8 @@ read_member_functions (struct field_info *fip, char **pp, struct type *type,
complaint (&symfile_complaints,
_("member function type missing, got '%c'"),
(*pp)[-1]);
- /* Fall through into normal member function. */
+ /* Normal member function. */
+ /* Fall through. */
case '.':
/* normal member function. */
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 7eb6cdc..e9e8ca7 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3100,7 +3100,7 @@ section_is_mapped (struct obj_section *osect)
if (osect->ovly_mapped == -1)
gdbarch_overlay_update (gdbarch, osect);
}
- /* fall thru to manual case */
+ /* fall thru */
case ovly_on: /* overlay debugging manual */
return osect->ovly_mapped == 1;
}
diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c
index 507baf2..70e031c 100644
--- a/gdb/xcoffread.c
+++ b/gdb/xcoffread.c
@@ -2507,9 +2507,9 @@ scan_xcoff_symtab (struct objfile *objfile)
}
/* FALLTHROUGH */
+ case C_FCN:
/* C_FCN is .bf and .ef symbols. I think it is sufficient
to handle only the C_FUN and C_EXT. */
- case C_FCN:
case C_BSTAT:
case C_ESTAT:
--
2.7.4
^ permalink raw reply [flat|nested] 12+ messages in thread
* [RFA 3/3] Fix "obvious" fall-through warnings
2016-09-27 18:16 [RFA 0/3] Fix some -Wimplicit-fallthrough warnings Tom Tromey
2016-09-27 18:16 ` [RFA 2/3] Add missing ATTRIBUTE_NORETURNs Tom Tromey
2016-09-27 18:16 ` [RFA 1/3] Fix "fall through" comments Tom Tromey
@ 2016-09-27 18:52 ` Tom Tromey
2 siblings, 0 replies; 12+ messages in thread
From: Tom Tromey @ 2016-09-27 18:52 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
This patch fixes the subset of -Wimplicit-fallthrough warnings that I
considered obvious. In most cases it was obvious from context that
falling through was desired; here I added the appropriate comment. In
a couple of cases it seemed clear that a "break" was missing.
2016-09-27 Tom Tromey <tom@tromey.com>
* utils.c (can_dump_core) <LIMIT_CUR>: Add fall-through comment.
* mi/mi-main.c (mi_cmd_trace_frame_collected) <REGISTERS_FORMAT>:
Add missing "break".
* mi/mi-cmd-stack.c (mi_cmd_stack_list_locals) <NO_FRAME_FILTERS>:
Add missing "break".
* eval.c (fetch_subexp_value) <MEMORY_ERROR>: Add fall-through
comment.
* d-valprint.c (d_val_print) <TYPE_CODE_STRUCT>: Add fall-through
comment.
* coffread.c (coff_symtab_read) <C_LABEL>: Add fall-through
comment.
---
gdb/ChangeLog | 14 ++++++++++++++
gdb/coffread.c | 1 +
gdb/d-valprint.c | 1 +
gdb/eval.c | 1 +
gdb/mi/mi-cmd-stack.c | 1 +
gdb/mi/mi-main.c | 1 +
gdb/utils.c | 1 +
7 files changed, 20 insertions(+)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 83b051f..511dedc 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,19 @@
2016-09-27 Tom Tromey <tom@tromey.com>
+ * utils.c (can_dump_core) <LIMIT_CUR>: Add fall-through comment.
+ * mi/mi-main.c (mi_cmd_trace_frame_collected) <REGISTERS_FORMAT>:
+ Add missing "break".
+ * mi/mi-cmd-stack.c (mi_cmd_stack_list_locals) <NO_FRAME_FILTERS>:
+ Add missing "break".
+ * eval.c (fetch_subexp_value) <MEMORY_ERROR>: Add fall-through
+ comment.
+ * d-valprint.c (d_val_print) <TYPE_CODE_STRUCT>: Add fall-through
+ comment.
+ * coffread.c (coff_symtab_read) <C_LABEL>: Add fall-through
+ comment.
+
+2016-09-27 Tom Tromey <tom@tromey.com>
+
* dwarf2loc.c (unimplemented): Add ATTRIBUTE_NORETURN.
* completer.h (throw_max_completions_reached_error): Add
ATTRIBUTE_NORETURN.
diff --git a/gdb/coffread.c b/gdb/coffread.c
index 49d6803..d3ebe97 100644
--- a/gdb/coffread.c
+++ b/gdb/coffread.c
@@ -932,6 +932,7 @@ coff_symtab_read (long symtab_offset, unsigned int nsyms,
backtraces, so filter them out (from phdm@macqel.be). */
if (within_function)
break;
+ /* Fall through. */
case C_STAT:
case C_THUMBLABEL:
case C_THUMBSTAT:
diff --git a/gdb/d-valprint.c b/gdb/d-valprint.c
index 620688b..4166a59 100644
--- a/gdb/d-valprint.c
+++ b/gdb/d-valprint.c
@@ -88,6 +88,7 @@ d_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
stream, recurse, val, options);
if (ret == 0)
break;
+ /* Fall through. */
default:
c_val_print (type, valaddr, embedded_offset, address, stream,
recurse, val, options);
diff --git a/gdb/eval.c b/gdb/eval.c
index 00a107c..1f2fb00 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -237,6 +237,7 @@ fetch_subexp_value (struct expression *exp, int *pc, struct value **valp,
case MEMORY_ERROR:
if (!preserve_errors)
break;
+ /* Fall through. */
default:
throw_exception (ex);
break;
diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c
index 390fc7e..b51650d 100644
--- a/gdb/mi/mi-cmd-stack.c
+++ b/gdb/mi/mi-cmd-stack.c
@@ -246,6 +246,7 @@ mi_cmd_stack_list_locals (char *command, char **argv, int argc)
{
case NO_FRAME_FILTERS:
raw_arg = oind;
+ break;
case SKIP_UNAVAILABLE:
skip_unavailable = 1;
break;
diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c
index 1913157..3b604e5 100644
--- a/gdb/mi/mi-main.c
+++ b/gdb/mi/mi-main.c
@@ -2815,6 +2815,7 @@ mi_cmd_trace_frame_collected (char *command, char **argv, int argc)
break;
case REGISTERS_FORMAT:
registers_format = oarg[0];
+ break;
case MEMORY_CONTENTS:
memory_contents = 1;
break;
diff --git a/gdb/utils.c b/gdb/utils.c
index 9a83053..9d11780 100644
--- a/gdb/utils.c
+++ b/gdb/utils.c
@@ -562,6 +562,7 @@ can_dump_core (enum resource_limit_kind limit_kind)
case LIMIT_CUR:
if (rlim.rlim_cur == 0)
return 0;
+ /* Fall through. */
case LIMIT_MAX:
if (rlim.rlim_max == 0)
--
2.7.4
^ permalink raw reply [flat|nested] 12+ messages in thread