public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return
@ 2023-12-21  7:01 Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 02/20] sim: add ATTRIBUTE_FALLTHROUGH for local code Mike Frysinger
                   ` (18 more replies)
  0 siblings, 19 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

All funcs already call other funcs that don't return.  The mips port is
the only exception because its generic exception handler can return in
the case of normal exceptions.  So while the exceptions its signal handler
triggers doesn't return, we can't express that conditional logic.  So add
some useless abort calls to make the compiler happy.
---
 sim/common/sim-core.h            | 2 +-
 sim/cris/sim-main.h              | 2 +-
 sim/frv/sim-main.h               | 2 +-
 sim/iq2000/sim-main.h            | 2 +-
 sim/lm32/sim-main.h              | 2 +-
 sim/m32r/sim-main.h              | 2 +-
 sim/m4/sim_ac_option_warnings.m4 | 1 +
 sim/mips/interp.c                | 6 ++++--
 sim/mips/sim-main.h              | 2 +-
 sim/mn10300/mn10300-sim.h        | 3 ++-
 sim/mn10300/sim-main.h           | 2 +-
 11 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/sim/common/sim-core.h b/sim/common/sim-core.h
index 34826f76edb8..bad69876e4f6 100644
--- a/sim/common/sim-core.h
+++ b/sim/common/sim-core.h
@@ -40,7 +40,7 @@ typedef void (SIM_CORE_SIGNAL_FN)
      (SIM_DESC sd, sim_cpu *cpu, sim_cia cia, unsigned map, int nr_bytes,
       address_word addr, transfer_type transfer, sim_core_signals sig);
 
-extern SIM_CORE_SIGNAL_FN sim_core_signal;
+extern SIM_CORE_SIGNAL_FN sim_core_signal ATTRIBUTE_NORETURN;
 
 
 /* basic types */
diff --git a/sim/cris/sim-main.h b/sim/cris/sim-main.h
index abebe2bafc1f..8fa6ff522bcc 100644
--- a/sim/cris/sim-main.h
+++ b/sim/cris/sim-main.h
@@ -201,7 +201,7 @@ struct cris_sim_cpu {
 /* Misc.  */
 
 /* Catch address exceptions.  */
-extern SIM_CORE_SIGNAL_FN cris_core_signal;
+extern SIM_CORE_SIGNAL_FN cris_core_signal ATTRIBUTE_NORETURN;
 #define SIM_CORE_SIGNAL(SD,CPU,CIA,MAP,NR_BYTES,ADDR,TRANSFER,ERROR) \
 cris_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), \
 		  (TRANSFER), (ERROR))
diff --git a/sim/frv/sim-main.h b/sim/frv/sim-main.h
index f2fbcce2b214..b9f99fb3dede 100644
--- a/sim/frv/sim-main.h
+++ b/sim/frv/sim-main.h
@@ -102,7 +102,7 @@ struct frv_sim_cpu {
 /* Misc.  */
 
 /* Catch address exceptions.  */
-extern SIM_CORE_SIGNAL_FN frv_core_signal;
+extern SIM_CORE_SIGNAL_FN frv_core_signal ATTRIBUTE_NORETURN;
 #define SIM_CORE_SIGNAL(SD,CPU,CIA,MAP,NR_BYTES,ADDR,TRANSFER,ERROR) \
 frv_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), \
 		  (TRANSFER), (ERROR))
diff --git a/sim/iq2000/sim-main.h b/sim/iq2000/sim-main.h
index dcd7ed4682f8..82865943e3bc 100644
--- a/sim/iq2000/sim-main.h
+++ b/sim/iq2000/sim-main.h
@@ -37,7 +37,7 @@ struct iq2000_sim_cpu {
 /* Misc.  */
 
 /* Catch address exceptions.  */
-extern SIM_CORE_SIGNAL_FN iq2000_core_signal;
+extern SIM_CORE_SIGNAL_FN iq2000_core_signal ATTRIBUTE_NORETURN;
 #define SIM_CORE_SIGNAL(SD,CPU,CIA,MAP,NR_BYTES,ADDR,TRANSFER,ERROR) \
 iq2000_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), \
 		  (TRANSFER), (ERROR))
diff --git a/sim/lm32/sim-main.h b/sim/lm32/sim-main.h
index e0e967c4233b..c252dc8f6411 100644
--- a/sim/lm32/sim-main.h
+++ b/sim/lm32/sim-main.h
@@ -51,7 +51,7 @@ struct lm32_sim_cpu
 /* Misc.  */
 
 /* Catch address exceptions.  */
-extern SIM_CORE_SIGNAL_FN lm32_core_signal;
+extern SIM_CORE_SIGNAL_FN lm32_core_signal ATTRIBUTE_NORETURN;
 #define SIM_CORE_SIGNAL(SD,CPU,CIA,MAP,NR_BYTES,ADDR,TRANSFER,ERROR) \
 lm32_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), \
 		  (TRANSFER), (ERROR))
diff --git a/sim/m32r/sim-main.h b/sim/m32r/sim-main.h
index 89502f2240e3..31758a153a10 100644
--- a/sim/m32r/sim-main.h
+++ b/sim/m32r/sim-main.h
@@ -21,7 +21,7 @@
 /* Misc.  */
 
 /* Catch address exceptions.  */
-extern SIM_CORE_SIGNAL_FN m32r_core_signal;
+extern SIM_CORE_SIGNAL_FN m32r_core_signal ATTRIBUTE_NORETURN;
 #define SIM_CORE_SIGNAL(SD,CPU,CIA,MAP,NR_BYTES,ADDR,TRANSFER,ERROR) \
 m32r_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), \
 		  (TRANSFER), (ERROR))
diff --git a/sim/m4/sim_ac_option_warnings.m4 b/sim/m4/sim_ac_option_warnings.m4
index 9f1487f93d0c..3da1c6a2e4a8 100644
--- a/sim/m4/sim_ac_option_warnings.m4
+++ b/sim/m4/sim_ac_option_warnings.m4
@@ -45,6 +45,7 @@ dnl C++ -Wno-mismatched-tags
 -Wno-error=deprecated-register
 dnl C++ -Wsuggest-override
 -Wduplicated-cond
+dnl -Wshadow=local
 dnl C++ -Wdeprecated-copy
 dnl C++ -Wdeprecated-copy-dtor
 dnl C++ -Wredundant-move
diff --git a/sim/mips/interp.c b/sim/mips/interp.c
index cb650a552483..255807f67906 100644
--- a/sim/mips/interp.c
+++ b/sim/mips/interp.c
@@ -2498,7 +2498,8 @@ mips_core_signal (SIM_DESC sd,
 		      (unsigned long) addr, (unsigned long) ip);
       COP0_BADVADDR = addr;
       SignalExceptionDataReference();
-      break;
+      /* Shouldn't actually be reached.  */
+      abort ();
 
     case sim_core_unaligned_signal:
       sim_io_eprintf (sd, "mips-core: %d byte %s to unaligned address 0x%lx at 0x%lx\n",
@@ -2509,7 +2510,8 @@ mips_core_signal (SIM_DESC sd,
 	SignalExceptionAddressLoad();
       else
 	SignalExceptionAddressStore();
-      break;
+      /* Shouldn't actually be reached.  */
+      abort ();
 
     default:
       sim_engine_abort (sd, cpu, cia,
diff --git a/sim/mips/sim-main.h b/sim/mips/sim-main.h
index d5a0dc81b628..5d358564f281 100644
--- a/sim/mips/sim-main.h
+++ b/sim/mips/sim-main.h
@@ -1038,7 +1038,7 @@ extern int DSPLO_REGNUM[4];
 extern int DSPHI_REGNUM[4];
 
 INLINE_SIM_MAIN (void) pending_tick (SIM_DESC sd, sim_cpu *cpu, address_word cia);
-extern SIM_CORE_SIGNAL_FN mips_core_signal;
+extern SIM_CORE_SIGNAL_FN mips_core_signal ATTRIBUTE_NORETURN;
 
 char* pr_addr (address_word addr);
 char* pr_uword64 (uword64 addr);
diff --git a/sim/mn10300/mn10300-sim.h b/sim/mn10300/mn10300-sim.h
index 3eadc0fe1780..493df3893e99 100644
--- a/sim/mn10300/mn10300-sim.h
+++ b/sim/mn10300/mn10300-sim.h
@@ -196,7 +196,8 @@ INLINE_SIM_MAIN (void) genericOr (uint32_t source, uint32_t destReg);
 INLINE_SIM_MAIN (void) genericXor (uint32_t source, uint32_t destReg);
 INLINE_SIM_MAIN (void) genericBtst (uint32_t leftOpnd, uint32_t rightOpnd);
 INLINE_SIM_MAIN (void) do_syscall (SIM_DESC sd);
-void program_interrupt (SIM_DESC sd, sim_cpu *cpu, sim_cia cia, SIM_SIGNAL sig);
+void program_interrupt (SIM_DESC sd, sim_cpu *cpu, sim_cia cia, SIM_SIGNAL sig)
+  ATTRIBUTE_NORETURN;
 
 void mn10300_cpu_exception_trigger(SIM_DESC sd, sim_cpu* cpu, address_word pc);
 void mn10300_cpu_exception_suspend(SIM_DESC sd, sim_cpu* cpu, int exception);
diff --git a/sim/mn10300/sim-main.h b/sim/mn10300/sim-main.h
index d08b13dc5315..b0f0d12c6512 100644
--- a/sim/mn10300/sim-main.h
+++ b/sim/mn10300/sim-main.h
@@ -48,6 +48,6 @@ mn10300_core_signal ((SD), (CPU), (CIA), (MAP), (NR_BYTES), (ADDR), (TRANSFER),
 #include "mn10300-sim.h"
 #endif
 
-extern SIM_CORE_SIGNAL_FN mn10300_core_signal;
+extern SIM_CORE_SIGNAL_FN mn10300_core_signal ATTRIBUTE_NORETURN;
 
 #endif
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 02/20] sim: add ATTRIBUTE_FALLTHROUGH for local code
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 03/20] sim: common: fix -Wimplicit-fallthrough warnings Mike Frysinger
                   ` (17 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

We'll replace various /* fall through */ comments so compilers can
actually understand what the code is doing.
---
 sim/common/defs.h | 3 +++
 sim/ppc/defs.h    | 3 +++
 2 files changed, 6 insertions(+)

diff --git a/sim/common/defs.h b/sim/common/defs.h
index 0f4062c2031d..01db1804b4cd 100644
--- a/sim/common/defs.h
+++ b/sim/common/defs.h
@@ -25,6 +25,9 @@
 /* Include gnulib's various configure tests.  */
 #include "gnulib/config.h"
 
+/* This comes from gnulib.  Export it until ansidecl.h handles it.  */
+#define ATTRIBUTE_FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH
+
 /* Reset macros that our config.h will provide.  */
 #undef PACKAGE
 #undef PACKAGE_BUGREPORT
diff --git a/sim/ppc/defs.h b/sim/ppc/defs.h
index 276063d4b74e..ab7a142b8994 100644
--- a/sim/ppc/defs.h
+++ b/sim/ppc/defs.h
@@ -23,6 +23,9 @@
 /* Include gnulib's various configure tests.  */
 #include "gnulib/config.h"
 
+/* This comes from gnulib.  Export it until ansidecl.h handles it.  */
+#define ATTRIBUTE_FALLTHROUGH _GL_ATTRIBUTE_FALLTHROUGH
+
 /* Reset macros that our config.h will provide.  */
 #undef PACKAGE
 #undef PACKAGE_BUGREPORT
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 03/20] sim: common: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 02/20] sim: add ATTRIBUTE_FALLTHROUGH for local code Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 04/20] sim: aarch64: " Mike Frysinger
                   ` (16 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Replace some fall through comments with the attribute.
---
 sim/common/dv-cfi.c        | 6 ++++--
 sim/common/hw-properties.c | 2 +-
 sim/common/sim-memopt.c    | 4 ++--
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/sim/common/dv-cfi.c b/sim/common/dv-cfi.c
index 95498d7a2f40..b9c9acdb6820 100644
--- a/sim/common/dv-cfi.c
+++ b/sim/common/dv-cfi.c
@@ -210,7 +210,7 @@ cfi_unshift_addr (struct cfi *cfi, unsigned addr)
 {
   switch (cfi->width)
     {
-    case 4: addr >>= 1; /* fallthrough.  */
+    case 4: addr >>= 1; ATTRIBUTE_FALLTHROUGH;
     case 2: addr >>= 1;
     }
   return addr;
@@ -414,7 +414,7 @@ cfi_io_write_buffer (struct hw *me, const void *source, int space,
 	  goto done;
 	}
 
-      /* Fall through.  */
+      ATTRIBUTE_FALLTHROUGH;
 
     default:
       if (!cfi->cmdset->write (me, cfi, source, offset, value, nr_bytes))
@@ -490,6 +490,8 @@ cfi_io_read_buffer (struct hw *me, void *dest, int space,
 	  break;
 	}
 
+      ATTRIBUTE_FALLTHROUGH;
+
     default:
       if (!cfi->cmdset->read (me, cfi, dest, offset, shifted_offset, nr_bytes))
 	HW_TRACE ((me, "unhandled state %s", state_names[cfi->state]));
diff --git a/sim/common/hw-properties.c b/sim/common/hw-properties.c
index f1d7a77ec50d..42b4d3a7426d 100644
--- a/sim/common/hw-properties.c
+++ b/sim/common/hw-properties.c
@@ -829,7 +829,7 @@ hw_find_string_array_property (struct hw *me,
       if (node->sizeof_array == 0
 	  || ((char*)node->array)[node->sizeof_array - 1] != '\0')
 	hw_abort (me, "property \"%s\" invalid for string array", property);
-      /* FALL THROUGH */
+      ATTRIBUTE_FALLTHROUGH;
     case string_array_property:
       ASSERT (node->sizeof_array > 0);
       ASSERT (((char*)node->array)[node->sizeof_array - 1] == '\0');
diff --git a/sim/common/sim-memopt.c b/sim/common/sim-memopt.c
index 7d46a864afc5..c179d6ab8109 100644
--- a/sim/common/sim-memopt.c
+++ b/sim/common/sim-memopt.c
@@ -300,10 +300,10 @@ parse_size (char *chp,
       break;
     case 'g': case 'G': /* Gigabyte suffix.  */
       *nr_bytes <<= 10;
-      /* Fall through.  */
+      ATTRIBUTE_FALLTHROUGH;
     case 'm': case 'M': /* Megabyte suffix.  */
       *nr_bytes <<= 10;
-      /* Fall through.  */
+      ATTRIBUTE_FALLTHROUGH;
     case 'k': case 'K': /* Kilobyte suffix.  */
       *nr_bytes <<= 10;
       /* Check for a modulo specifier after the suffix.  */
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 04/20] sim: aarch64: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 02/20] sim: add ATTRIBUTE_FALLTHROUGH for local code Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 03/20] sim: common: fix -Wimplicit-fallthrough warnings Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 05/20] sim: arm: " Mike Frysinger
                   ` (15 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Replace some fall through comments with the attribute, and add some
default abort calls when the compiler can't figure out that the set
of values were already fully enumerated in the switch statement.
---
 sim/aarch64/simulator.c | 40 ++++++++++++++++++++++++++--------------
 1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/sim/aarch64/simulator.c b/sim/aarch64/simulator.c
index 3dba1b7f0dc7..8825819a3910 100644
--- a/sim/aarch64/simulator.c
+++ b/sim/aarch64/simulator.c
@@ -129,11 +129,11 @@ expand_logical_immediate (uint32_t S, uint32_t R, uint32_t N)
   /* Replicate the value according to SIMD size.  */
   switch (simd_size)
     {
-    case  2: imm = (imm <<  2) | imm;
-    case  4: imm = (imm <<  4) | imm;
-    case  8: imm = (imm <<  8) | imm;
-    case 16: imm = (imm << 16) | imm;
-    case 32: imm = (imm << 32) | imm;
+    case  2: imm = (imm <<  2) | imm; ATTRIBUTE_FALLTHROUGH;
+    case  4: imm = (imm <<  4) | imm; ATTRIBUTE_FALLTHROUGH;
+    case  8: imm = (imm <<  8) | imm; ATTRIBUTE_FALLTHROUGH;
+    case 16: imm = (imm << 16) | imm; ATTRIBUTE_FALLTHROUGH;
+    case 32: imm = (imm << 32) | imm; ATTRIBUTE_FALLTHROUGH;
     case 64: break;
     default: return 0;
     }
@@ -2040,12 +2040,12 @@ extreg32 (sim_cpu *cpu, unsigned int lo, Extension extension)
     {
     case UXTB: return aarch64_get_reg_u8  (cpu, lo, NO_SP);
     case UXTH: return aarch64_get_reg_u16 (cpu, lo, NO_SP);
-    case UXTW: /* Fall through.  */
+    case UXTW: ATTRIBUTE_FALLTHROUGH;
     case UXTX: return aarch64_get_reg_u32 (cpu, lo, NO_SP);
     case SXTB: return aarch64_get_reg_s8  (cpu, lo, NO_SP);
     case SXTH: return aarch64_get_reg_s16 (cpu, lo, NO_SP);
-    case SXTW: /* Fall through.  */
-    case SXTX: /* Fall through.  */
+    case SXTW: ATTRIBUTE_FALLTHROUGH;
+    case SXTX: ATTRIBUTE_FALLTHROUGH;
     default:   return aarch64_get_reg_s32 (cpu, lo, NO_SP);
   }
 }
@@ -3346,7 +3346,7 @@ do_vec_MOV_immediate (sim_cpu *cpu)
 
     case 0xa: /* 16-bit, shift by 8.  */
       val <<= 8;
-      /* Fall through.  */
+      ATTRIBUTE_FALLTHROUGH;
     case 0x8: /* 16-bit, no shift.  */
       for (i = 0; i < (full ? 8 : 4); i++)
 	aarch64_set_vec_u16 (cpu, vd, i, val);
@@ -3355,7 +3355,7 @@ do_vec_MOV_immediate (sim_cpu *cpu)
     case 0xd: /* 32-bit, mask shift by 16.  */
       val <<= 8;
       val |= 0xFF;
-      /* Fall through.  */
+      ATTRIBUTE_FALLTHROUGH;
     case 0xc: /* 32-bit, mask shift by 8. */
       val <<= 8;
       val |= 0xFF;
@@ -3416,6 +3416,7 @@ do_vec_MVNI (sim_cpu *cpu)
 
     case 0xa: /* 16-bit, 8 bit shift. */
       val <<= 8;
+      ATTRIBUTE_FALLTHROUGH;
     case 0x8: /* 16-bit, no shift. */
       val = ~ val;
       for (i = 0; i < (full ? 8 : 4); i++)
@@ -3425,6 +3426,7 @@ do_vec_MVNI (sim_cpu *cpu)
     case 0xd: /* 32-bit, mask shift by 16.  */
       val <<= 8;
       val |= 0xFF;
+      ATTRIBUTE_FALLTHROUGH;
     case 0xc: /* 32-bit, mask shift by 8. */
       val <<= 8;
       val |= 0xFF;
@@ -4691,6 +4693,8 @@ do_vec_SCVTF (sim_cpu *cpu)
 				 aarch64_get_vec_##SOURCE##64 (cpu, vm, i) \
 				 ? -1ULL : 0);				\
 	  return;							\
+	default:							\
+	  HALT_UNALLOC;							\
 	}								\
     }									\
   while (0)
@@ -4726,6 +4730,8 @@ do_vec_SCVTF (sim_cpu *cpu)
 				 aarch64_get_vec_##SOURCE##64 (cpu, vn, i) \
 				 CMP 0 ? -1ULL : 0);			\
 	  return;							\
+	default:							\
+	  HALT_UNALLOC;							\
 	}								\
     }									\
   while (0)
@@ -5316,6 +5322,7 @@ do_vec_sub_long (sim_cpu *cpu)
     {
     case 2: /* SSUBL2.  */
       bias = 2;
+      ATTRIBUTE_FALLTHROUGH;
     case 0: /* SSUBL.  */
       switch (size)
 	{
@@ -5349,6 +5356,7 @@ do_vec_sub_long (sim_cpu *cpu)
 
     case 3: /* USUBL2.  */
       bias = 2;
+      ATTRIBUTE_FALLTHROUGH;
     case 1: /* USUBL.  */
       switch (size)
 	{
@@ -5811,6 +5819,7 @@ do_vec_xtl (sim_cpu *cpu)
     {
     case 2: /* SXTL2, SSHLL2.  */
       bias = 2;
+      ATTRIBUTE_FALLTHROUGH;
     case 0: /* SXTL, SSHLL.  */
       if (INSTR (21, 21))
 	{
@@ -5851,6 +5860,7 @@ do_vec_xtl (sim_cpu *cpu)
 
     case 3: /* UXTL2, USHLL2.  */
       bias = 2;
+      ATTRIBUTE_FALLTHROUGH;
     case 1: /* UXTL, USHLL.  */
       if (INSTR (21, 21))
 	{
@@ -8568,6 +8578,7 @@ dexSimpleFPIntegerConvert (sim_cpu *cpu)
 	case 1: scvtd32 (cpu); return;
 	case 2: scvtf (cpu); return;
 	case 3: scvtd (cpu); return;
+	default: HALT_UNALLOC;
 	}
 
     case 6:			/* FMOV GR, Vec.  */
@@ -8593,6 +8604,7 @@ dexSimpleFPIntegerConvert (sim_cpu *cpu)
 	case 1: fcvtszd32 (cpu); return;
 	case 2: fcvtszs (cpu); return;
 	case 3: fcvtszd (cpu); return;
+	default: HALT_UNALLOC;
 	}
 
     case 25: do_fcvtzu (cpu); return;
@@ -9186,7 +9198,7 @@ do_scalar_FCM (sim_cpu *cpu)
 	case 3: /* 011 */
 	  val1 = fabs (val1);
 	  val2 = fabs (val2);
-	  /* Fall through. */
+	  ATTRIBUTE_FALLTHROUGH;
 	case 2: /* 010 */
 	  result = val1 >= val2;
 	  break;
@@ -9194,7 +9206,7 @@ do_scalar_FCM (sim_cpu *cpu)
 	case 7: /* 111 */
 	  val1 = fabs (val1);
 	  val2 = fabs (val2);
-	  /* Fall through. */
+	  ATTRIBUTE_FALLTHROUGH;
 	case 6: /* 110 */
 	  result = val1 > val2;
 	  break;
@@ -9219,7 +9231,7 @@ do_scalar_FCM (sim_cpu *cpu)
     case 3: /* 011 */
       val1 = fabsf (val1);
       val2 = fabsf (val2);
-      /* Fall through. */
+      ATTRIBUTE_FALLTHROUGH;
     case 2: /* 010 */
       result = val1 >= val2;
       break;
@@ -9227,7 +9239,7 @@ do_scalar_FCM (sim_cpu *cpu)
     case 7: /* 111 */
       val1 = fabsf (val1);
       val2 = fabsf (val2);
-      /* Fall through. */
+      ATTRIBUTE_FALLTHROUGH;
     case 6: /* 110 */
       result = val1 > val2;
       break;
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 05/20] sim: arm: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (2 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 04/20] sim: aarch64: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 06/20] sim: avr: " Mike Frysinger
                   ` (14 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Replace some fall through comments with the attribute.
---
 sim/arm/armemu.c   | 6 +++---
 sim/arm/armos.c    | 1 +
 sim/arm/thumbemu.c | 7 ++++---
 sim/arm/wrapper.c  | 4 ++--
 4 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/sim/arm/armemu.c b/sim/arm/armemu.c
index ab7454628ba0..2b8ae007cb56 100644
--- a/sim/arm/armemu.c
+++ b/sim/arm/armemu.c
@@ -4388,7 +4388,7 @@ check_PMUintr:
 		    ARMul_UndefInstr (state, instr);
 		  break;
 		}
-	      /* Drop through.  */
+	      ATTRIBUTE_FALLTHROUGH;
 
 	    case 0xc0:		/* Store , No WriteBack , Post Dec.  */
 	      ARMul_STC (state, instr, LHS);
@@ -4435,7 +4435,7 @@ check_PMUintr:
 		    ARMul_UndefInstr (state, instr);
 		  break;
 		}
-	      /* Drop through.  */
+	      ATTRIBUTE_FALLTHROUGH;
 
 	    case 0xc1:		/* Load , No WriteBack , Post Dec.  */
 	      ARMul_LDC (state, instr, LHS);
@@ -4622,7 +4622,7 @@ check_PMUintr:
 		  default:
 		    break;
 		  }
-	      /* Drop through.  */
+	      ATTRIBUTE_FALLTHROUGH;
 
 	    case 0xe0:
 	    case 0xe4:
diff --git a/sim/arm/armos.c b/sim/arm/armos.c
index 374861d7a5ec..6deb722d204d 100644
--- a/sim/arm/armos.c
+++ b/sim/arm/armos.c
@@ -832,6 +832,7 @@ ARMul_OSHandleSWI (ARMul_State * state, ARMword number)
 	    }
 	  break;
 	}
+      ATTRIBUTE_FALLTHROUGH;
 
     default:
       unhandled = TRUE;
diff --git a/sim/arm/thumbemu.c b/sim/arm/thumbemu.c
index 6915d23ec4cc..99f51ef34691 100644
--- a/sim/arm/thumbemu.c
+++ b/sim/arm/thumbemu.c
@@ -308,7 +308,7 @@ handle_T2_insn (ARMul_State * state,
 	  * pvalid = t_branch;
 	  break;
 	}
-      /* Fall through.  */
+      ATTRIBUTE_FALLTHROUGH;
     case 0x42:
     case 0x43:
     case 0x47:
@@ -2261,7 +2261,7 @@ ARMul_ThumbDecode (ARMul_State * state,
 		    | ((tinstr & 0x0078) >> 3);	/* Rd */
 		  break;
 		}
-	      /* Drop through.  */
+	      ATTRIBUTE_FALLTHROUGH;
 	    default:
 	    case 0x0:		/* UNDEFINED */
 	    case 0x4:		/* UNDEFINED */
@@ -2415,7 +2415,7 @@ ARMul_ThumbDecode (ARMul_State * state,
 		* ainstr = 0xE1200070 | ((tinstr & 0xf0) << 4) | (tinstr & 0xf);
 	      break;
 	    }
-	  /* Drop through.  */
+	  ATTRIBUTE_FALLTHROUGH;
 	default:
 	  /* Everything else is an undefined instruction.  */
 	  handle_v6_thumb_insn (state, tinstr, next_instr, pc, ainstr, & valid);
@@ -2601,6 +2601,7 @@ ARMul_ThumbDecode (ARMul_State * state,
 	}
       /* else we fall through to process the second half of the BL */
       pc += 2;			/* point the pc at the 2nd half */
+      ATTRIBUTE_FALLTHROUGH;
     case 31:			/* BL instruction 2 */
       if (state->is_v6)
 	{
diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c
index 52b4dc7d6e09..8d928a6f79f9 100644
--- a/sim/arm/wrapper.c
+++ b/sim/arm/wrapper.c
@@ -251,7 +251,7 @@ sim_create_inferior (SIM_DESC sd ATTRIBUTE_UNUSED,
 	(sim_callback,
 	 "Unknown machine type '%d'; please update sim_create_inferior.\n",
 	 mach);
-      /* fall through */
+      ATTRIBUTE_FALLTHROUGH;
 
     case 0:
       /* We wouldn't set the machine type with earlier toolchains, so we
@@ -310,7 +310,7 @@ sim_create_inferior (SIM_DESC sd ATTRIBUTE_UNUSED,
 	  ARMul_SelectProcessor (state, ARM_v5_Prop | ARM_v5e_Prop | ARM_XScale_Prop);
 	  break;
 	}
-      /* Otherwise drop through.  */
+      ATTRIBUTE_FALLTHROUGH;
 
     case bfd_mach_arm_5T:
       ARMul_SelectProcessor (state, ARM_v5_Prop);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 06/20] sim: avr: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (3 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 05/20] sim: arm: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 07/20] sim: bfin: " Mike Frysinger
                   ` (13 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Replace some fall through comments with the attribute.
---
 sim/avr/interp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sim/avr/interp.c b/sim/avr/interp.c
index eef4ad96ec2f..377398e94e26 100644
--- a/sim/avr/interp.c
+++ b/sim/avr/interp.c
@@ -896,7 +896,7 @@ step_once (SIM_CPU *cpu)
 
       case OP_reti:
 	sram[SREG] |= SREG_I;
-	/* Fall through */
+	ATTRIBUTE_FALLTHROUGH;
       case OP_ret:
 	{
 	  const struct avr_sim_state *state = AVR_SIM_STATE (CPU_STATE (cpu));
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 07/20] sim: bfin: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (4 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 06/20] sim: avr: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 08/20] sim: cris: " Mike Frysinger
                   ` (12 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Add the attribute to places where we want to fall thru.
---
 sim/bfin/dv-bfin_dma.c   | 1 +
 sim/bfin/dv-bfin_twi.c   | 1 +
 sim/bfin/dv-bfin_uart2.c | 1 +
 sim/bfin/interp.c        | 2 ++
 4 files changed, 5 insertions(+)

diff --git a/sim/bfin/dv-bfin_dma.c b/sim/bfin/dv-bfin_dma.c
index a3384700b2bf..4d2b95d24836 100644
--- a/sim/bfin/dv-bfin_dma.c
+++ b/sim/bfin/dv-bfin_dma.c
@@ -173,6 +173,7 @@ bfin_dma_process_desc (struct hw *me, struct bfin_dma *dma)
 	  dma->ndph = _flows[1];
 	  --ndsize;
 	  ++flows;
+	  ATTRIBUTE_FALLTHROUGH;
 	case DMAFLOW_SMALL:
 	  dma->ndpl = _flows[0];
 	  --ndsize;
diff --git a/sim/bfin/dv-bfin_twi.c b/sim/bfin/dv-bfin_twi.c
index 0ea224ca63cb..5a25320cb10c 100644
--- a/sim/bfin/dv-bfin_twi.c
+++ b/sim/bfin/dv-bfin_twi.c
@@ -118,6 +118,7 @@ bfin_twi_io_write_buffer (struct hw *me, const void *source, int space,
       break;
     case mmr_offset(xmt_data8):
       value &= 0xff;
+      ATTRIBUTE_FALLTHROUGH;
     case mmr_offset(xmt_data16):
       twi->xmt_fifo = value;
       break;
diff --git a/sim/bfin/dv-bfin_uart2.c b/sim/bfin/dv-bfin_uart2.c
index 0b55a30a55d3..5c8a50659b3c 100644
--- a/sim/bfin/dv-bfin_uart2.c
+++ b/sim/bfin/dv-bfin_uart2.c
@@ -158,6 +158,7 @@ bfin_uart_io_read_buffer (struct hw *me, void *dest,
     case mmr_offset(lsr):
       uart->lsr &= ~(DR | THRE | TEMT);
       uart->lsr |= bfin_uart_get_status (me);
+      ATTRIBUTE_FALLTHROUGH;
     case mmr_offset(thr):
     case mmr_offset(msr):
     case mmr_offset(dll):
diff --git a/sim/bfin/interp.c b/sim/bfin/interp.c
index df1d1b3f70f2..bb0b83c01c2f 100644
--- a/sim/bfin/interp.c
+++ b/sim/bfin/interp.c
@@ -396,12 +396,14 @@ bfin_syscall (SIM_CPU *cpu)
       goto sys_finish;
     case CB_SYS_setuid:
       sc.arg1 &= 0xffff;
+      ATTRIBUTE_FALLTHROUGH;
     case CB_SYS_setuid32:
       tbuf += sprintf (tbuf, "setuid(%u)", args[0]);
       sc.result = setuid (sc.arg1);
       goto sys_finish;
     case CB_SYS_setgid:
       sc.arg1 &= 0xffff;
+      ATTRIBUTE_FALLTHROUGH;
     case CB_SYS_setgid32:
       tbuf += sprintf (tbuf, "setgid(%u)", args[0]);
       sc.result = setgid (sc.arg1);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 08/20] sim: cris: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (5 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 07/20] sim: bfin: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 09/20] sim: erc32: " Mike Frysinger
                   ` (11 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Replace some fall through comments with the attribute.
---
 sim/cris/cris-tmpl.c | 4 ++++
 sim/cris/traps.c     | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/sim/cris/cris-tmpl.c b/sim/cris/cris-tmpl.c
index b39583cdb207..232085cf452e 100644
--- a/sim/cris/cris-tmpl.c
+++ b/sim/cris/cris-tmpl.c
@@ -67,6 +67,10 @@ MY (f_break_handler) (SIM_CPU *cpu, USI breaknum, USI pc)
       cris_break_13_handler (cpu, /* TARGET_SYS_exit */ 1, 0,
 			     0, 0, 0, 0, 0, pc);
 
+      /* This shouldn't be reached, but we can't mark break 13 as noreturn
+	 since there are some calls which should return.  */
+      ATTRIBUTE_FALLTHROUGH;
+
     default:
       abort ();
     }
diff --git a/sim/cris/traps.c b/sim/cris/traps.c
index 29b1b7cfdb38..cd4cfd9f0208 100644
--- a/sim/cris/traps.c
+++ b/sim/cris/traps.c
@@ -1527,7 +1527,7 @@ cris_break_13_handler (SIM_CPU *current_cpu, USI callnum, USI arg1,
 		  retval = TARGET_O_WRONLY;
 		  break;
 		}
-	      /* FALLTHROUGH */
+	      ATTRIBUTE_FALLTHROUGH;
 	    default:
 	      /* Nothing else is implemented.  */
 	      retval
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 09/20] sim: erc32: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (6 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 08/20] sim: cris: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 10/20] sim: frv: " Mike Frysinger
                   ` (10 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Add the attribute where it seems to make sense.
---
 sim/erc32/erc32.c |  1 +
 sim/erc32/exec.c  | 10 ++++++++++
 sim/erc32/sis.c   |  1 +
 3 files changed, 12 insertions(+)

diff --git a/sim/erc32/erc32.c b/sim/erc32/erc32.c
index c4abab2889c5..b37183a26af0 100644
--- a/sim/erc32/erc32.c
+++ b/sim/erc32/erc32.c
@@ -799,6 +799,7 @@ mec_write(uint32_t addr, uint32_t data)
     case MEC_UARTA:
     case MEC_UARTB:
         if (data & 0xFFFFFF00) mecparerror();
+        ATTRIBUTE_FALLTHROUGH;
     case MEC_UART_CTRL:
         if (data & 0xFF00FF00) mecparerror();
 	write_uart(addr, data);
diff --git a/sim/erc32/exec.c b/sim/erc32/exec.c
index 1187bccfec78..10a9dae603c0 100644
--- a/sim/erc32/exec.c
+++ b/sim/erc32/exec.c
@@ -1220,6 +1220,7 @@ dispatch_instruction(struct pstate *sregs)
 	switch (op3) {
 	case LDDA:
 	    if (!chk_asi(sregs, &asi, op3)) break;
+	    ATTRIBUTE_FALLTHROUGH;
 	case LDD:
 	    if (address & 0x7) {
 		sregs->trap = TRAP_UNALI;
@@ -1250,6 +1251,7 @@ dispatch_instruction(struct pstate *sregs)
 
 	case LDA:
 	    if (!chk_asi(sregs, &asi, op3)) break;
+	    ATTRIBUTE_FALLTHROUGH;
 	case LD:
 	    if (address & 0x3) {
 		sregs->trap = TRAP_UNALI;
@@ -1265,6 +1267,7 @@ dispatch_instruction(struct pstate *sregs)
 	    break;
 	case LDSTUBA:
 	    if (!chk_asi(sregs, &asi, op3)) break;
+	    ATTRIBUTE_FALLTHROUGH;
 	case LDSTUB:
 	    mexc = memory_read(asi, address, &data, 0, &ws);
 	    sregs->hold += ws;
@@ -1288,6 +1291,7 @@ dispatch_instruction(struct pstate *sregs)
 	case LDSBA:
 	case LDUBA:
 	    if (!chk_asi(sregs, &asi, op3)) break;
+	    ATTRIBUTE_FALLTHROUGH;
 	case LDSB:
 	case LDUB:
 	    mexc = memory_read(asi, address, &data, 0, &ws);
@@ -1305,6 +1309,7 @@ dispatch_instruction(struct pstate *sregs)
 	case LDSHA:
 	case LDUHA:
 	    if (!chk_asi(sregs, &asi, op3)) break;
+	    ATTRIBUTE_FALLTHROUGH;
 	case LDSH:
 	case LDUH:
 	    if (address & 0x1) {
@@ -1426,6 +1431,7 @@ dispatch_instruction(struct pstate *sregs)
 
 	case STA:
 	    if (!chk_asi(sregs, &asi, op3)) break;
+	    ATTRIBUTE_FALLTHROUGH;
 	case ST:
 	    if (address & 0x3) {
 		sregs->trap = TRAP_UNALI;
@@ -1439,6 +1445,7 @@ dispatch_instruction(struct pstate *sregs)
 	    break;
 	case STBA:
 	    if (!chk_asi(sregs, &asi, op3)) break;
+	    ATTRIBUTE_FALLTHROUGH;
 	case STB:
 	    mexc = memory_write(asi, address, rdd, 0, &ws);
 	    sregs->hold += ws;
@@ -1448,6 +1455,7 @@ dispatch_instruction(struct pstate *sregs)
 	    break;
 	case STDA:
 	    if (!chk_asi(sregs, &asi, op3)) break;
+	    ATTRIBUTE_FALLTHROUGH;
 	case STD:
 	    if (address & 0x7) {
 		sregs->trap = TRAP_UNALI;
@@ -1505,6 +1513,7 @@ dispatch_instruction(struct pstate *sregs)
 	    break;
 	case STHA:
 	    if (!chk_asi(sregs, &asi, op3)) break;
+	    ATTRIBUTE_FALLTHROUGH;
 	case STH:
 	    if (address & 0x1) {
 		sregs->trap = TRAP_UNALI;
@@ -1561,6 +1570,7 @@ dispatch_instruction(struct pstate *sregs)
 	    break;
 	case SWAPA:
 	    if (!chk_asi(sregs, &asi, op3)) break;
+	    ATTRIBUTE_FALLTHROUGH;
 	case SWAP:
 	    if (address & 0x3) {
 		sregs->trap = TRAP_UNALI;
diff --git a/sim/erc32/sis.c b/sim/erc32/sis.c
index 7445c7b1a4bb..2de493a3528e 100644
--- a/sim/erc32/sis.c
+++ b/sim/erc32/sis.c
@@ -281,6 +281,7 @@ main(int argc, char **argv)
 	    break;
 	case CTRL_C:
 	    printf("\b\bInterrupt!\n");
+	    ATTRIBUTE_FALLTHROUGH;
 	case TIME_OUT:
 	    printf(" Stopped at time %" PRIu64 " (%.3f ms)\n", ebase.simtime,
 	      ((double) ebase.simtime / (double) sregs.freq) / 1000.0);
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 10/20] sim: frv: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (7 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 09/20] sim: erc32: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 11/20] sim: m68hc11: " Mike Frysinger
                   ` (9 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Replace some fall through comments with the attribute.
---
 sim/frv/cache.c      | 2 +-
 sim/frv/interrupts.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sim/frv/cache.c b/sim/frv/cache.c
index c2beb39d3ef8..2d0fe5a590e9 100644
--- a/sim/frv/cache.c
+++ b/sim/frv/cache.c
@@ -136,7 +136,7 @@ frv_cache_reconfigure (SIM_CPU *current_cpu, FRV_CACHE *cache)
 	      break;
 	    }
 	}
-      /* fall through */
+      ATTRIBUTE_FALLTHROUGH;
     default:
       /* Set the cache to its original settings.  */
       cache->sets = cache->configured_sets;
diff --git a/sim/frv/interrupts.c b/sim/frv/interrupts.c
index baf058f18d4a..979360738bab 100644
--- a/sim/frv/interrupts.c
+++ b/sim/frv/interrupts.c
@@ -835,7 +835,7 @@ set_exception_status_registers (
 	{
 	case FRV_DIVISION_EXCEPTION:
 	  set_isr_exception_fields (current_cpu, item);
-	  /* fall thru to set reg_index.  */
+	  ATTRIBUTE_FALLTHROUGH;  /* To set reg_index.  */
 	case FRV_COMMIT_EXCEPTION:
 	  /* For fr550, always use ESR0.  */
 	  if (STATE_ARCHITECTURE (sd)->mach == bfd_mach_fr550)
@@ -855,7 +855,7 @@ set_exception_status_registers (
 	  break;
 	case FRV_DATA_ACCESS_EXCEPTION:
 	  set_daec = 1;
-	  /* fall through */
+	  ATTRIBUTE_FALLTHROUGH;
 	case FRV_DATA_ACCESS_MMU_MISS:
 	case FRV_MEM_ADDRESS_NOT_ALIGNED:
 	  /* Get the appropriate ESR, EPCR, EAR and EDR.
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 11/20] sim: m68hc11: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (8 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 10/20] sim: frv: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 12/20] sim: mcore: fix Wimplicit-fallthrough warnings Mike Frysinger
                   ` (8 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Seems like these register operations intended on falling thru.
---
 sim/m68hc11/dv-m68hc11sio.c | 1 +
 sim/m68hc11/dv-m68hc11spi.c | 1 +
 2 files changed, 2 insertions(+)

diff --git a/sim/m68hc11/dv-m68hc11sio.c b/sim/m68hc11/dv-m68hc11sio.c
index d5ecbe4f822e..03b44613c180 100644
--- a/sim/m68hc11/dv-m68hc11sio.c
+++ b/sim/m68hc11/dv-m68hc11sio.c
@@ -523,6 +523,7 @@ m68hc11sio_io_read_buffer (struct hw *me,
     case M6811_SCSR:
       controller->rx_clear_scsr = m68hc11_cpu->ios[M6811_SCSR]
         & (M6811_RDRF | M6811_IDLE | M6811_OR | M6811_NF | M6811_FE);
+      ATTRIBUTE_FALLTHROUGH;
       
     case M6811_BAUD:
     case M6811_SCCR1:
diff --git a/sim/m68hc11/dv-m68hc11spi.c b/sim/m68hc11/dv-m68hc11spi.c
index e552fd5de9a8..ac44e6ed7e2f 100644
--- a/sim/m68hc11/dv-m68hc11spi.c
+++ b/sim/m68hc11/dv-m68hc11spi.c
@@ -405,6 +405,7 @@ m68hc11spi_io_read_buffer (struct hw *me,
     case M6811_SPSR:
       controller->rx_clear_scsr = m68hc11_cpu->ios[M6811_SCSR]
         & (M6811_SPIF | M6811_WCOL | M6811_MODF);
+      ATTRIBUTE_FALLTHROUGH;
       
     case M6811_SPCR:
       val = m68hc11_cpu->ios[base];
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 12/20] sim: mcore: fix Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (9 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 11/20] sim: m68hc11: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 13/20] sim: mips: fix -Wimplicit-fallthrough warnings Mike Frysinger
                   ` (7 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Seems like these decodes were intended to fallthru.
---
 sim/mcore/interp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sim/mcore/interp.c b/sim/mcore/interp.c
index b0c2cc2b3177..d24af0d94720 100644
--- a/sim/mcore/interp.c
+++ b/sim/mcore/interp.c
@@ -1105,6 +1105,7 @@ step_once (SIM_DESC sd, SIM_CPU *cpu)
 	    fprintf (stderr,
 		     "func call: r2 = %x r3 = %x r4 = %x r5 = %x r6 = %x r7 = %x\n",
 		     gr[2], gr[3], gr[4], gr[5], gr[6], gr[7]);
+	  ATTRIBUTE_FALLTHROUGH;
 	case 0x70:					/* jmpi */
 	  pc = rlat ((pc + ((inst & 0xFF) << 2)) & 0xFFFFFFFC);
 	  memops++;
@@ -1192,6 +1193,7 @@ step_once (SIM_DESC sd, SIM_CPU *cpu)
 	case 0xF8: case 0xF9: case 0xFA: case 0xFB:
 	case 0xFC: case 0xFD: case 0xFE: case 0xFF:	/* bsr */
 	  gr[15] = pc;
+	  ATTRIBUTE_FALLTHROUGH;
 	case 0xF0: case 0xF1: case 0xF2: case 0xF3:
 	case 0xF4: case 0xF5: case 0xF6: case 0xF7:	/* br */
 	  {
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 13/20] sim: mips: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (10 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 12/20] sim: mcore: fix Wimplicit-fallthrough warnings Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 14/20] sim: or1k: " Mike Frysinger
                   ` (6 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Seems like these cases were meant to fallthru.
---
 sim/mips/cp1.c     | 4 ++++
 sim/mips/interp.c  | 4 +++-
 sim/mips/m16e.igen | 6 ++++++
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/sim/mips/cp1.c b/sim/mips/cp1.c
index 3e2d5d9f474d..9d1dfe5d8dde 100644
--- a/sim/mips/cp1.c
+++ b/sim/mips/cp1.c
@@ -262,6 +262,7 @@ store_fpr (sim_cpu *cpu,
 	{
 	case fmt_uninterpreted_32:
 	  fmt = fmt_uninterpreted;
+	  ATTRIBUTE_FALLTHROUGH;
 	case fmt_single:
 	case fmt_word:
 	  if (STATE_VERBOSE_P (SD))
@@ -274,6 +275,7 @@ store_fpr (sim_cpu *cpu,
 
 	case fmt_uninterpreted_64:
 	  fmt = fmt_uninterpreted;
+	  ATTRIBUTE_FALLTHROUGH;
 	case fmt_uninterpreted:
 	case fmt_double:
 	case fmt_long:
@@ -294,6 +296,7 @@ store_fpr (sim_cpu *cpu,
 	{
 	case fmt_uninterpreted_32:
 	  fmt = fmt_uninterpreted;
+	  ATTRIBUTE_FALLTHROUGH;
 	case fmt_single:
 	case fmt_word:
 	  FGR[fpr] = (value & 0xFFFFFFFF);
@@ -302,6 +305,7 @@ store_fpr (sim_cpu *cpu,
 
 	case fmt_uninterpreted_64:
 	  fmt = fmt_uninterpreted;
+	  ATTRIBUTE_FALLTHROUGH;
 	case fmt_uninterpreted:
 	case fmt_double:
 	case fmt_long:
diff --git a/sim/mips/interp.c b/sim/mips/interp.c
index 255807f67906..708e27f6b2b7 100644
--- a/sim/mips/interp.c
+++ b/sim/mips/interp.c
@@ -1247,7 +1247,7 @@ sim_monitor (SIM_DESC sd,
 	if (A0 == 0)	/* waitflag == NOWAIT */
 	  V0 = (unsigned_word)-1;
       }
-     /* Drop through to case 11 */
+     ATTRIBUTE_FALLTHROUGH;
 
     case 11: /* char inbyte(void) */
       {
@@ -1904,6 +1904,7 @@ signal_exception (SIM_DESC sd,
 	 }
        /* else fall through to normal exception processing */
        sim_io_eprintf(sd,"ReservedInstruction at PC = 0x%s\n", pr_addr (cia));
+       ATTRIBUTE_FALLTHROUGH;
      }
 
     default:
@@ -2329,6 +2330,7 @@ decode_coproc (SIM_DESC sd,
 				  "Warning: PC 0x%lx:interp.c decode_coproc DEADC0DE\n",
 				  (unsigned long)cia);
 		GPR[rt] = 0xDEADC0DE; /* CPR[0,rd] */
+		ATTRIBUTE_FALLTHROUGH;
 		/* CPR[0,rd] = GPR[rt]; */
 	      default:
 		if (op == cp0_mfc0 || op == cp0_dmfc0)
diff --git a/sim/mips/m16e.igen b/sim/mips/m16e.igen
index fda54cacad99..9facbd47bd61 100644
--- a/sim/mips/m16e.igen
+++ b/sim/mips/m16e.igen
@@ -212,16 +212,22 @@
   switch (xsregs) {
   case 7:
     do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[30]);
+    ATTRIBUTE_FALLTHROUGH;
   case 6:
     do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[23]);
+    ATTRIBUTE_FALLTHROUGH;
   case 5:
     do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[22]);
+    ATTRIBUTE_FALLTHROUGH;
   case 4:
     do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[21]);
+    ATTRIBUTE_FALLTHROUGH;
   case 3:
     do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[20]);
+    ATTRIBUTE_FALLTHROUGH;
   case 2:
     do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[19]);
+    ATTRIBUTE_FALLTHROUGH;
   case 1:
     do_store (SD_,AccessLength_WORD, temp -= 4, 0, GPR[18]);
   }
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 14/20] sim: or1k: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (11 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 13/20] sim: mips: fix -Wimplicit-fallthrough warnings Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 15/20] sim: ppc: " Mike Frysinger
                   ` (5 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Replace some fall through comments with the attribute.
---
 sim/or1k/or1k.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sim/or1k/or1k.c b/sim/or1k/or1k.c
index 73ddeac87ade..b32e9b1e6401 100644
--- a/sim/or1k/or1k.c
+++ b/sim/or1k/or1k.c
@@ -270,7 +270,7 @@ or1k32bf_nop (sim_cpu *current_cpu, USI uimm16)
 
     case NOP_EXIT:
       sim_io_printf (CPU_STATE (current_cpu), "exit(%d)\n", GET_H_GPR (3));
-      /* fall through */
+      ATTRIBUTE_FALLTHROUGH;
     case NOP_EXIT_SILENT:
       sim_engine_halt (sd, current_cpu, NULL, CPU_PC_GET (current_cpu),
 		       sim_exited, GET_H_GPR (3));
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 15/20] sim: ppc: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (12 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 14/20] sim: or1k: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 16/20] sim: riscv: " Mike Frysinger
                   ` (4 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Replace some fall through comments with the attribute.
---
 sim/ppc/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sim/ppc/device.c b/sim/ppc/device.c
index 4537e89b38dc..45dda89caa83 100644
--- a/sim/ppc/device.c
+++ b/sim/ppc/device.c
@@ -1453,7 +1453,7 @@ device_find_string_array_property(device *me,
     if (node->sizeof_array == 0
 	|| ((char*)node->array)[node->sizeof_array - 1] != '\0')
       device_error(me, "property %s invalid for string array", property);
-    /* FALL THROUGH */
+    ATTRIBUTE_FALLTHROUGH;
   case string_array_property:
     ASSERT(node->sizeof_array > 0);
     ASSERT(((char*)node->array)[node->sizeof_array - 1] == '\0');
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 16/20] sim: riscv: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (13 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 15/20] sim: ppc: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 17/20] sim: rl78: " Mike Frysinger
                   ` (3 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

---
 sim/riscv/sim-main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sim/riscv/sim-main.c b/sim/riscv/sim-main.c
index afdfcf506566..4d2053453950 100644
--- a/sim/riscv/sim-main.c
+++ b/sim/riscv/sim-main.c
@@ -126,6 +126,7 @@ store_csr (SIM_CPU *cpu, const char *name, int csr, unsigned_word *reg,
     case CSR_INSTRETH:
     case CSR_TIMEH:
       RISCV_ASSERT_RV32 (cpu, "CSR: %s", name);
+      ATTRIBUTE_FALLTHROUGH;
 
     /* All the rest are immutable.  */
     default:
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 17/20] sim: rl78: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (14 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 16/20] sim: riscv: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 18/20] sim: rx: " Mike Frysinger
                   ` (2 subsequent siblings)
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Seems like this code was meant to fallthru.
---
 sim/rl78/rl78.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sim/rl78/rl78.c b/sim/rl78/rl78.c
index 8f11c09d87d8..447f56fe02f0 100644
--- a/sim/rl78/rl78.c
+++ b/sim/rl78/rl78.c
@@ -499,6 +499,7 @@ decode_opcode (void)
 	CLOCKS (3); /* note: adds two clocks, total 5 clocks */
       else
 	CLOCKS (2); /* note: adds one clock, total 4 clocks */
+      ATTRIBUTE_FALLTHROUGH;
     case RLO_branch:
       tprintf ("BRANCH: ");
       v = GPC ();
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 18/20] sim: rx: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (15 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 17/20] sim: rl78: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 19/20] sim: sh: " Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 20/20] sim: warnings: enable -Wimplicit-fallthrough=5 Mike Frysinger
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

Replace some fall through comments with the attribute.
---
 sim/rx/rx.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sim/rx/rx.c b/sim/rx/rx.c
index 7c02a336bd59..f4f785b938b5 100644
--- a/sim/rx/rx.c
+++ b/sim/rx/rx.c
@@ -411,7 +411,7 @@ get_op (const RX_Opcode_Decoded *rd, int i)
 
     case RX_Operand_Predec:	/* [-Rn] */
       put_reg (o->reg, get_reg (o->reg) - size2bytes[o->size]);
-      /* fall through */
+      ATTRIBUTE_FALLTHROUGH;
     case RX_Operand_Postinc:	/* [Rn+] */
     case RX_Operand_Zero_Indirect:	/* [Rn + 0] */
     case RX_Operand_Indirect:	/* [Rn + addend] */
@@ -583,7 +583,7 @@ put_op (const RX_Opcode_Decoded *rd, int i, int v)
 
     case RX_Operand_Predec:	/* [-Rn] */
       put_reg (o->reg, get_reg (o->reg) - size2bytes[o->size]);
-      /* fall through */
+      ATTRIBUTE_FALLTHROUGH;
     case RX_Operand_Postinc:	/* [Rn+] */
     case RX_Operand_Zero_Indirect:	/* [Rn + 0] */
     case RX_Operand_Indirect:	/* [Rn + addend] */
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 19/20] sim: sh: fix -Wimplicit-fallthrough warnings
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (16 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 18/20] sim: rx: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  2023-12-21  7:01 ` [PATCH/committed 20/20] sim: warnings: enable -Wimplicit-fallthrough=5 Mike Frysinger
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

These generate conditional insns where it tests, then fallsthru.
---
 sim/sh/gencode.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sim/sh/gencode.c b/sim/sh/gencode.c
index 1835cf92ff3f..9683dc46b86a 100644
--- a/sim/sh/gencode.c
+++ b/sim/sh/gencode.c
@@ -3296,6 +3296,7 @@ ppi_gensim (void)
 	    case 'c':
 	      printf ("      if ((((iword >> 8) ^ DSR) & 1) == 0)\n");
 	      printf ("\treturn;\n");
+	      printf ("      ATTRIBUTE_FALLTHROUGH;\n");
 	      printf ("    }\n");
 	      printf ("  case %d:\n", p->index + 1);
 	      printf ("    {\n");
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH/committed 20/20] sim: warnings: enable -Wimplicit-fallthrough=5
  2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
                   ` (17 preceding siblings ...)
  2023-12-21  7:01 ` [PATCH/committed 19/20] sim: sh: " Mike Frysinger
@ 2023-12-21  7:01 ` Mike Frysinger
  18 siblings, 0 replies; 20+ messages in thread
From: Mike Frysinger @ 2023-12-21  7:01 UTC (permalink / raw)
  To: gdb-patches

It caught some legitimate bugs, so clearly it's helpful.
---
 sim/configure                    | 1 +
 sim/m4/sim_ac_option_warnings.m4 | 1 +
 2 files changed, 2 insertions(+)

diff --git a/sim/m4/sim_ac_option_warnings.m4 b/sim/m4/sim_ac_option_warnings.m4
index 3da1c6a2e4a8..bdb99c496527 100644
--- a/sim/m4/sim_ac_option_warnings.m4
+++ b/sim/m4/sim_ac_option_warnings.m4
@@ -44,6 +44,7 @@ build_warnings="-Wall -Wpointer-arith
 dnl C++ -Wno-mismatched-tags
 -Wno-error=deprecated-register
 dnl C++ -Wsuggest-override
+-Wimplicit-fallthrough=5
 -Wduplicated-cond
 dnl -Wshadow=local
 dnl C++ -Wdeprecated-copy
-- 
2.43.0


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2023-12-21  7:02 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-21  7:01 [PATCH/committed 01/20] sim: signal: mark signal callback funcs as noreturn since they don't return Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 02/20] sim: add ATTRIBUTE_FALLTHROUGH for local code Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 03/20] sim: common: fix -Wimplicit-fallthrough warnings Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 04/20] sim: aarch64: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 05/20] sim: arm: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 06/20] sim: avr: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 07/20] sim: bfin: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 08/20] sim: cris: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 09/20] sim: erc32: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 10/20] sim: frv: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 11/20] sim: m68hc11: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 12/20] sim: mcore: fix Wimplicit-fallthrough warnings Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 13/20] sim: mips: fix -Wimplicit-fallthrough warnings Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 14/20] sim: or1k: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 15/20] sim: ppc: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 16/20] sim: riscv: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 17/20] sim: rl78: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 18/20] sim: rx: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 19/20] sim: sh: " Mike Frysinger
2023-12-21  7:01 ` [PATCH/committed 20/20] sim: warnings: enable -Wimplicit-fallthrough=5 Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).