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()
# GCC or compatible compilers such as Clang
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)
set(RELEASE_WARNING_FLAGS "${WARNING_FLAGS}")
else()

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

@ -65,6 +65,7 @@ std::string RollbackAction::toString() const
os << ", " << itos(n_new.param2);
os << ", " << serializeJsonString(n_new.meta);
os << ')';
break;
case TYPE_MODIFY_INVENTORY_STACK:
os << "modify_inventory_stack (";
os << serializeJsonString(inventory_location);
@ -73,6 +74,7 @@ std::string RollbackAction::toString() const
os << ", " << (inventory_add ? "add" : "remove");
os << ", " << serializeJsonString(inventory_stack.getItemString());
os << ')';
break;
default:
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
// FIRELIKE drawtype both should default to having
// backface_culling to false.
[[fallthrough]];
case NDT_MESH:
case NDT_LIQUID:
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;
switch (len & 7) {
case 7: h ^= (u64)data2[6] << 48;
case 6: h ^= (u64)data2[5] << 40;
case 5: h ^= (u64)data2[4] << 32;
case 4: h ^= (u64)data2[3] << 24;
case 3: h ^= (u64)data2[2] << 16;
case 2: h ^= (u64)data2[1] << 8;
case 7: h ^= (u64)data2[6] << 48; [[fallthrough]];
case 6: h ^= (u64)data2[5] << 40; [[fallthrough]];
case 5: h ^= (u64)data2[4] << 32; [[fallthrough]];
case 4: h ^= (u64)data2[3] << 24; [[fallthrough]];
case 3: h ^= (u64)data2[2] << 16; [[fallthrough]];
case 2: h ^= (u64)data2[1] << 8; [[fallthrough]];
case 1: h ^= (u64)data2[0];
h *= m;
}