build: add [[fallthrough]] attributes

This commit is contained in:
Danny Robson 2022-08-18 13:11:38 +10:00
parent 2e0f6c6923
commit 1828687a7e
3 changed files with 38 additions and 36 deletions

View File

@ -20,8 +20,8 @@ namespace cruft::hash::murmur {
uint32_t h = 0;
switch (len % sizeof (uint32_t)) {
case 3: h += bytes[2] << 16;
case 2: h += bytes[1] << 8;
case 3: h += bytes[2] << 16; [[fallthrough]];
case 2: h += bytes[1] << 8; [[fallthrough]];
case 1: h += bytes[0];
break;
@ -43,12 +43,12 @@ namespace cruft::hash::murmur {
uint64_t h = 0;
switch (len % sizeof (uint64_t)) {
case 7: h += uint64_t(bytes[6]) << 48;
case 6: h += uint64_t(bytes[5]) << 40;
case 5: h += uint64_t(bytes[4]) << 32;
case 4: h += uint64_t(bytes[3]) << 24;
case 3: h += uint64_t(bytes[2]) << 16;
case 2: h += uint64_t(bytes[1]) << 8;
case 7: h += uint64_t(bytes[6]) << 48; [[fallthrough]];
case 6: h += uint64_t(bytes[5]) << 40; [[fallthrough]];
case 5: h += uint64_t(bytes[4]) << 32; [[fallthrough]];
case 4: h += uint64_t(bytes[3]) << 24; [[fallthrough]];
case 3: h += uint64_t(bytes[2]) << 16; [[fallthrough]];
case 2: h += uint64_t(bytes[1]) << 8; [[fallthrough]];
case 1: h += uint64_t(bytes[0]);
break;
@ -70,20 +70,20 @@ namespace cruft::hash::murmur {
std::array<uint32_t,4> result {0,0,0,0};
switch (len % 16) {
case 15: result[3] |= bytes[14] << 16;
case 14: result[3] |= bytes[13] << 8;
case 13: result[3] |= bytes[12] << 0;
case 12: result[2] |= bytes[11] << 24;
case 11: result[2] |= bytes[10] << 16;
case 10: result[2] |= bytes[ 9] << 8;
case 9: result[2] |= bytes[ 8] << 0;
case 8: result[1] |= bytes[ 7] << 24;
case 7: result[1] |= bytes[ 6] << 16;
case 6: result[1] |= bytes[ 5] << 8;
case 5: result[1] |= bytes[ 4] << 0;
case 4: result[0] |= bytes[ 3] << 24;
case 3: result[0] |= bytes[ 2] << 16;
case 2: result[0] |= bytes[ 1] << 8;
case 15: result[3] |= bytes[14] << 16; [[fallthrough]];
case 14: result[3] |= bytes[13] << 8; [[fallthrough]];
case 13: result[3] |= bytes[12] << 0; [[fallthrough]];
case 12: result[2] |= bytes[11] << 24; [[fallthrough]];
case 11: result[2] |= bytes[10] << 16; [[fallthrough]];
case 10: result[2] |= bytes[ 9] << 8; [[fallthrough]];
case 9: result[2] |= bytes[ 8] << 0; [[fallthrough]];
case 8: result[1] |= bytes[ 7] << 24; [[fallthrough]];
case 7: result[1] |= bytes[ 6] << 16; [[fallthrough]];
case 6: result[1] |= bytes[ 5] << 8; [[fallthrough]];
case 5: result[1] |= bytes[ 4] << 0; [[fallthrough]];
case 4: result[0] |= bytes[ 3] << 24; [[fallthrough]];
case 3: result[0] |= bytes[ 2] << 16; [[fallthrough]];
case 2: result[0] |= bytes[ 1] << 8; [[fallthrough]];
case 1: result[0] |= bytes[ 0] << 0;
break;
@ -106,21 +106,21 @@ namespace cruft::hash::murmur {
switch(len & 15)
{
case 15: result[1] |= uint64_t{bytes[14]} << 48;
case 14: result[1] |= uint64_t{bytes[13]} << 40;
case 13: result[1] |= uint64_t{bytes[12]} << 32;
case 12: result[1] |= uint64_t{bytes[11]} << 24;
case 11: result[1] |= uint64_t{bytes[10]} << 16;
case 10: result[1] |= uint64_t{bytes[ 9]} << 8;
case 9: result[1] |= uint64_t{bytes[ 8]} << 0;
case 15: result[1] |= uint64_t{bytes[14]} << 48; [[fallthrough]];
case 14: result[1] |= uint64_t{bytes[13]} << 40; [[fallthrough]];
case 13: result[1] |= uint64_t{bytes[12]} << 32; [[fallthrough]];
case 12: result[1] |= uint64_t{bytes[11]} << 24; [[fallthrough]];
case 11: result[1] |= uint64_t{bytes[10]} << 16; [[fallthrough]];
case 10: result[1] |= uint64_t{bytes[ 9]} << 8; [[fallthrough]];
case 9: result[1] |= uint64_t{bytes[ 8]} << 0; [[fallthrough]];
case 8: result[0] |= uint64_t{bytes[ 7]} << 56;
case 7: result[0] |= uint64_t{bytes[ 6]} << 48;
case 6: result[0] |= uint64_t{bytes[ 5]} << 40;
case 5: result[0] |= uint64_t{bytes[ 4]} << 32;
case 4: result[0] |= uint64_t{bytes[ 3]} << 24;
case 3: result[0] |= uint64_t{bytes[ 2]} << 16;
case 2: result[0] |= uint64_t{bytes[ 1]} << 8;
case 8: result[0] |= uint64_t{bytes[ 7]} << 56; [[fallthrough]];
case 7: result[0] |= uint64_t{bytes[ 6]} << 48; [[fallthrough]];
case 6: result[0] |= uint64_t{bytes[ 5]} << 40; [[fallthrough]];
case 5: result[0] |= uint64_t{bytes[ 4]} << 32; [[fallthrough]];
case 4: result[0] |= uint64_t{bytes[ 3]} << 24; [[fallthrough]];
case 3: result[0] |= uint64_t{bytes[ 2]} << 16; [[fallthrough]];
case 2: result[0] |= uint64_t{bytes[ 1]} << 8; [[fallthrough]];
case 1: result[0] |= uint64_t{bytes[ 0]} << 0;
break;

View File

@ -34,6 +34,7 @@ cruft::parse::si (cruft::view<char const*> const src)
case 'G': case 'g': return dst * 1024 * 1024 * 1024;
case 'T': case 't': return dst * 1024 * 1024 * 1024 * 1024;
}
[[fallthrough]];
default:
return cruft::unexpected (std::errc::invalid_argument);

View File

@ -82,6 +82,7 @@ cruft::debug::validator<cruft::types::description>::is_valid (
WARN_RETURN (val.width == 0 || val.width > 8, false);
WARN_RETURN (val.arity == 0 || val.arity > 16, false);
WARN_RETURN (val.alignment == 0 || val.alignment > 64, false);
return true;
// All bets are off. Have fun.
case cruft::types::category::NONE: