From a3cc8182b2ae05290b0eafa74b70746d7befc0e4 Mon Sep 17 00:00:00 2001 From: Mark Wielaard Date: Wed, 2 Nov 2016 13:29:26 +0100 Subject: Add GCC7 -Wimplicit-fallthrough support/fixes. GCC7 will have a new -Wimplicit-fallthrough warning. It did catch one small buglet in elflint option procession. So it seems useful to enable to make sure all swatch case fallthroughs are deliberate. Add configure check to detect whether gcc support -Wimplicit-fallthrough and enable it. Add fixes and explicit fallthrough comments where necessary. Signed-off-by: Mark Wielaard --- backends/ChangeLog | 11 +++++++++++ backends/i386_regs.c | 1 + backends/i386_retval.c | 3 +-- backends/linux-core-note.c | 4 ++-- backends/m68k_retval.c | 4 +--- backends/ppc_regs.c | 2 +- backends/x86_64_regs.c | 1 + 7 files changed, 18 insertions(+), 8 deletions(-) (limited to 'backends') diff --git a/backends/ChangeLog b/backends/ChangeLog index 53d29081..1c561b50 100644 --- a/backends/ChangeLog +++ b/backends/ChangeLog @@ -1,3 +1,14 @@ +2016-11-02 Mark Wielaard + + * i386_regs.c (i386_register_info): Add fallthrough comment. + * i386_retval.c (i386_return_value_location): Move fallthrough + comment. + * linux-core-note.c (core_note): Adjust fallthrough comment. + * m68k_retval.c (m68k_return_value_location): Move fallthrough + comment. + * ppc_regs.c (ppc_register_info): Add fallthrough comment. + * x86_64_regs.c (x86_64_register_info): Likewise. + 2016-08-09 Jose E. Marchesi * sparc_attrs.c (sparc_check_object_attribute): Fix the diff --git a/backends/i386_regs.c b/backends/i386_regs.c index fb8ded33..fd963a62 100644 --- a/backends/i386_regs.c +++ b/backends/i386_regs.c @@ -92,6 +92,7 @@ i386_register_info (Ebl *ebl __attribute__ ((unused)), case 5: case 8: *type = DW_ATE_address; + /* Fallthrough */ case 0 ... 3: case 6 ... 7: name[0] = 'e'; diff --git a/backends/i386_retval.c b/backends/i386_retval.c index 9da797d5..4aa646fe 100644 --- a/backends/i386_retval.c +++ b/backends/i386_retval.c @@ -122,9 +122,8 @@ i386_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) return nloc_intreg; if (size <= 8) return nloc_intregpair; - - /* Else fall through. */ } + /* Fallthrough */ case DW_TAG_structure_type: case DW_TAG_class_type: diff --git a/backends/linux-core-note.c b/backends/linux-core-note.c index a4ec0be0..67638d70 100644 --- a/backends/linux-core-note.c +++ b/backends/linux-core-note.c @@ -225,8 +225,8 @@ EBLHOOK(core_note) (const GElf_Nhdr *nhdr, const char *name, case sizeof "CORE": if (memcmp (name, "CORE", nhdr->n_namesz) == 0) break; - /* Buggy old Linux kernels didn't terminate "LINUX". - Fall through. */ + /* Buggy old Linux kernels didn't terminate "LINUX". */ + /* Fall through. */ case sizeof "LINUX": if (memcmp (name, "LINUX", nhdr->n_namesz) == 0) diff --git a/backends/m68k_retval.c b/backends/m68k_retval.c index 2dd285a0..c68ed022 100644 --- a/backends/m68k_retval.c +++ b/backends/m68k_retval.c @@ -134,10 +134,8 @@ m68k_return_value_location (Dwarf_Die *functypedie, const Dwarf_Op **locp) return nloc_intreg; if (size <= 8) return nloc_intregpair; - - /* Else fall through. */ } - + /* Fallthrough */ case DW_TAG_structure_type: case DW_TAG_class_type: case DW_TAG_union_type: diff --git a/backends/ppc_regs.c b/backends/ppc_regs.c index 4b92a9aa..bcf4f7a3 100644 --- a/backends/ppc_regs.c +++ b/backends/ppc_regs.c @@ -140,7 +140,7 @@ ppc_register_info (Ebl *ebl __attribute__ ((unused)), case 100: if (*bits == 32) return stpcpy (name, "mq") + 1 - name; - + /* Fallthrough */ case 102 ... 107: name[0] = 's'; name[1] = 'p'; diff --git a/backends/x86_64_regs.c b/backends/x86_64_regs.c index 2172d9f1..84304407 100644 --- a/backends/x86_64_regs.c +++ b/backends/x86_64_regs.c @@ -87,6 +87,7 @@ x86_64_register_info (Ebl *ebl __attribute__ ((unused)), case 6 ... 7: *type = DW_ATE_address; + /* Fallthrough */ case 0 ... 5: name[0] = 'r'; name[1] = baseregs[regno][0]; -- cgit v1.2.3