[PATCH/committed,01/20] sim: signal: mark signal callback funcs as noreturn since they don't return

Message ID 20231221070127.19142-1-vapier@gentoo.org
State New
Headers
Series [PATCH/committed,01/20] sim: signal: mark signal callback funcs as noreturn since they don't return |

Commit Message

Mike Frysinger Dec. 21, 2023, 7:01 a.m. UTC
  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(-)
  

Patch

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