Skip to content

Commit

Permalink
Enable -Wimplicit-fallthrough and use [[fallthrough]] attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Desour authored and sfan5 committed Jun 15, 2023
1 parent 9c348d0 commit 5e6d144
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Expand Up @@ -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()
Expand Down
1 change: 1 addition & 0 deletions src/client/hud.cpp
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/rollback_interface.cpp
Expand Up @@ -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);
Expand All @@ -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>";
}
Expand Down
1 change: 1 addition & 0 deletions src/script/common/c_content.cpp
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions src/util/numeric.cpp
Expand Up @@ -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;
}
Expand Down

0 comments on commit 5e6d144

Please sign in to comment.