Enable -Wimplicit-fallthrough and use [[fallthrough]] attribute

This commit is contained in:
Desour 2023-06-12 22:23:32 +02:00 committed by sfan5
parent 9c348d057e
commit 5e6d144567
5 changed files with 11 additions and 7 deletions

@ -761,7 +761,7 @@ if(MSVC)
else() else()
# GCC or compatible compilers such as Clang # GCC or compatible compilers such as Clang
set(WARNING_FLAGS "-Wall -Wextra") set(WARNING_FLAGS "-Wall -Wextra")
set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-parameter -Wno-implicit-fallthrough") set(WARNING_FLAGS "${WARNING_FLAGS} -Wno-unused-parameter")
if(WARN_ALL) if(WARN_ALL)
set(RELEASE_WARNING_FLAGS "${WARNING_FLAGS}") set(RELEASE_WARNING_FLAGS "${WARNING_FLAGS}")
else() else()

@ -440,6 +440,7 @@ void Hud::drawLuaElements(const v3s16 &camera_offset)
case HUD_ELEM_IMAGE_WAYPOINT: { case HUD_ELEM_IMAGE_WAYPOINT: {
if (!calculateScreenPos(camera_offset, e, &pos)) if (!calculateScreenPos(camera_offset, e, &pos))
break; break;
[[fallthrough]];
} }
case HUD_ELEM_IMAGE: { case HUD_ELEM_IMAGE: {
video::ITexture *texture = tsrc->getTexture(e->text); video::ITexture *texture = tsrc->getTexture(e->text);

@ -65,6 +65,7 @@ std::string RollbackAction::toString() const
os << ", " << itos(n_new.param2); os << ", " << itos(n_new.param2);
os << ", " << serializeJsonString(n_new.meta); os << ", " << serializeJsonString(n_new.meta);
os << ')'; os << ')';
break;
case TYPE_MODIFY_INVENTORY_STACK: case TYPE_MODIFY_INVENTORY_STACK:
os << "modify_inventory_stack ("; os << "modify_inventory_stack (";
os << serializeJsonString(inventory_location); os << serializeJsonString(inventory_location);
@ -73,6 +74,7 @@ std::string RollbackAction::toString() const
os << ", " << (inventory_add ? "add" : "remove"); os << ", " << (inventory_add ? "add" : "remove");
os << ", " << serializeJsonString(inventory_stack.getItemString()); os << ", " << serializeJsonString(inventory_stack.getItemString());
os << ')'; os << ')';
break;
default: default:
return "<unknown action>"; return "<unknown action>";
} }

@ -478,6 +478,7 @@ TileDef read_tiledef(lua_State *L, int index, u8 drawtype, bool special)
// "break" is omitted here intentionaly, as PLANTLIKE // "break" is omitted here intentionaly, as PLANTLIKE
// FIRELIKE drawtype both should default to having // FIRELIKE drawtype both should default to having
// backface_culling to false. // backface_culling to false.
[[fallthrough]];
case NDT_MESH: case NDT_MESH:
case NDT_LIQUID: case NDT_LIQUID:
default_culling = false; default_culling = false;

@ -90,12 +90,12 @@ u64 murmur_hash_64_ua(const void *key, int len, unsigned int seed)
const unsigned char *data2 = (const unsigned char *)data; const unsigned char *data2 = (const unsigned char *)data;
switch (len & 7) { switch (len & 7) {
case 7: h ^= (u64)data2[6] << 48; case 7: h ^= (u64)data2[6] << 48; [[fallthrough]];
case 6: h ^= (u64)data2[5] << 40; case 6: h ^= (u64)data2[5] << 40; [[fallthrough]];
case 5: h ^= (u64)data2[4] << 32; case 5: h ^= (u64)data2[4] << 32; [[fallthrough]];
case 4: h ^= (u64)data2[3] << 24; case 4: h ^= (u64)data2[3] << 24; [[fallthrough]];
case 3: h ^= (u64)data2[2] << 16; case 3: h ^= (u64)data2[2] << 16; [[fallthrough]];
case 2: h ^= (u64)data2[1] << 8; case 2: h ^= (u64)data2[1] << 8; [[fallthrough]];
case 1: h ^= (u64)data2[0]; case 1: h ^= (u64)data2[0];
h *= m; h *= m;
} }