[Tarantool-patches] [PATCH luajit 13/19] ARM: Fix GCC 7 -Wimplicit-fallthrough warnings.

Sergey Kaplun skaplun at tarantool.org
Wed Aug 9 18:36:02 MSK 2023


From: Mike Pall <mike>

(cherry-picked from commit 9bd5a722bee2ee2c5b159a89937778b81be49915)

This patch adds the `/* fallthrough */` comments elsewhere, where it was
missing for the ARM build, so the `-Wimplicit-fallthrough` [1] warning
is trigerred.

Also, this commits sets the correspoinding flag in the
<cmake/SetTargetFlags.cmake>.

[1]: https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wimplicit-fallthrough

Sergey Kaplun:
* added the description for the commit

Part of tarantool/tarantool#8825
---
 cmake/SetTargetFlags.cmake | 6 ++++++
 src/lj_asm.c               | 2 +-
 src/lj_asm_arm.h           | 4 ++--
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/cmake/SetTargetFlags.cmake b/cmake/SetTargetFlags.cmake
index 3b9e481d..d309989e 100644
--- a/cmake/SetTargetFlags.cmake
+++ b/cmake/SetTargetFlags.cmake
@@ -8,6 +8,12 @@
 
 include(CheckUnwindTables)
 
+# Clang does not recognize comment markers.
+if (CMAKE_C_COMPILER_ID STREQUAL "GNU"
+    AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "7.1")
+  AppendFlags(TARGET_C_FLAGS -Wimplicit-fallthrough)
+endif()
+
 if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
   set(BUILDVM_MODE machasm)
 else() # Linux and FreeBSD.
diff --git a/src/lj_asm.c b/src/lj_asm.c
index 2d570bb9..25b96264 100644
--- a/src/lj_asm.c
+++ b/src/lj_asm.c
@@ -2176,8 +2176,8 @@ static void asm_setup_regsp(ASMState *as)
 #if LJ_SOFTFP
     case IR_MIN: case IR_MAX:
       if ((ir+1)->o != IR_HIOP) break;
-      /* fallthrough */
 #endif
+    /* fallthrough */
     /* C calls evict all scratch regs and return results in RID_RET. */
     case IR_SNEW: case IR_XSNEW: case IR_NEWREF: case IR_BUFPUT:
       if (REGARG_NUMGPR < 3 && as->evenspill < 3)
diff --git a/src/lj_asm_arm.h b/src/lj_asm_arm.h
index 6ae6e2f2..2894e5c9 100644
--- a/src/lj_asm_arm.h
+++ b/src/lj_asm_arm.h
@@ -979,7 +979,7 @@ static ARMIns asm_fxloadins(IRIns *ir)
   case IRT_I16: return ARMI_LDRSH;
   case IRT_U16: return ARMI_LDRH;
   case IRT_NUM: lua_assert(!LJ_SOFTFP); return ARMI_VLDR_D;
-  case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VLDR_S;
+  case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VLDR_S;  /* fallthrough */
   default: return ARMI_LDR;
   }
 }
@@ -990,7 +990,7 @@ static ARMIns asm_fxstoreins(IRIns *ir)
   case IRT_I8: case IRT_U8: return ARMI_STRB;
   case IRT_I16: case IRT_U16: return ARMI_STRH;
   case IRT_NUM: lua_assert(!LJ_SOFTFP); return ARMI_VSTR_D;
-  case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VSTR_S;
+  case IRT_FLOAT: if (!LJ_SOFTFP) return ARMI_VSTR_S;  /* fallthrough */
   default: return ARMI_STR;
   }
 }
-- 
2.41.0



More information about the Tarantool-patches mailing list