Use '[[fallthrough]]' attribute and enable relevant warning

This commit is contained in:
Vittorio Romeo 2021-12-03 15:53:01 +00:00 committed by Lukas Dürrenberger
parent 4e1fcb3775
commit dd14d7c57f
2 changed files with 9 additions and 9 deletions

View File

@ -65,7 +65,7 @@ function(set_file_warnings)
-Wsign-conversion # warn on sign conversions
-Wdouble-promotion # warn if float is implicit promoted to double
-Wformat=2 # warn on security issues around functions that format output (ie printf)
# -Wimplicit-fallthrough # warn when a missing break causes control flow to continue at the next case in a switch statement (disabled until better compiler support for explicit fallthrough is available)
-Wimplicit-fallthrough # warn when a missing break causes control flow to continue at the next case in a switch statement
${NON_ANDROID_CLANG_AND_GCC_WARNINGS}
)

View File

@ -62,11 +62,11 @@ In Utf<8>::decode(In begin, In end, Uint32& output, Uint32 replacement)
output = 0;
switch (trailingBytes)
{
case 5: output += static_cast<Uint8>(*begin++); output <<= 6; // fallthrough
case 4: output += static_cast<Uint8>(*begin++); output <<= 6; // fallthrough
case 3: output += static_cast<Uint8>(*begin++); output <<= 6; // fallthrough
case 2: output += static_cast<Uint8>(*begin++); output <<= 6; // fallthrough
case 1: output += static_cast<Uint8>(*begin++); output <<= 6; // fallthrough
case 5: output += static_cast<Uint8>(*begin++); output <<= 6; [[fallthrough]];
case 4: output += static_cast<Uint8>(*begin++); output <<= 6; [[fallthrough]];
case 3: output += static_cast<Uint8>(*begin++); output <<= 6; [[fallthrough]];
case 2: output += static_cast<Uint8>(*begin++); output <<= 6; [[fallthrough]];
case 1: output += static_cast<Uint8>(*begin++); output <<= 6; [[fallthrough]];
case 0: output += static_cast<Uint8>(*begin++);
}
output -= offsets[trailingBytes];
@ -114,9 +114,9 @@ Out Utf<8>::encode(Uint32 input, Out output, Uint8 replacement)
Uint8 bytes[4];
switch (bytestoWrite)
{
case 4: bytes[3] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6; // fallthrough
case 3: bytes[2] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6; // fallthrough
case 2: bytes[1] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6; // fallthrough
case 4: bytes[3] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6; [[fallthrough]];
case 3: bytes[2] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6; [[fallthrough]];
case 2: bytes[1] = static_cast<Uint8>((input | 0x80) & 0xBF); input >>= 6; [[fallthrough]];
case 1: bytes[0] = static_cast<Uint8> (input | firstBytes[bytestoWrite]);
}