Skip to content

Commit

Permalink
Add [[fallthrough]] attribute to case statements when appropriate.
Browse files Browse the repository at this point in the history
  • Loading branch information
Cory-Kramer committed Jul 28, 2023
1 parent 6c1a309 commit d1c90ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ elseif(MSVC)
# warning C4548: expression before comma has no effect; expected expression with side-effect
/wd4548

# warning C5051: attribute 'fallthrough' requires at least '/std:c++17'
/wd5051

# Make sure WinDef.h does not define min and max macros which
# will conflict with std::min() and std::max().
/DNOMINMAX
Expand Down
22 changes: 11 additions & 11 deletions opensubdiv/bfr/hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -388,47 +388,47 @@ void SpookyHash::Short(
{
case 15:
d += ((uint64)u.p8[14]) << 48;
// FALLTHRU
[[fallthrough]];
case 14:
d += ((uint64)u.p8[13]) << 40;
// FALLTHRU
[[fallthrough]];
case 13:
d += ((uint64)u.p8[12]) << 32;
// FALLTHRU
[[fallthrough]];
case 12:
d += u.p32[2];
c += u.p64[0];
break;
case 11:
d += ((uint64)u.p8[10]) << 16;
// FALLTHRU
[[fallthrough]];
case 10:
d += ((uint64)u.p8[9]) << 8;
// FALLTHRU
[[fallthrough]];
case 9:
d += (uint64)u.p8[8];
// FALLTHRU
[[fallthrough]];
case 8:
c += u.p64[0];
break;
case 7:
c += ((uint64)u.p8[6]) << 48;
// FALLTHRU
[[fallthrough]];
case 6:
c += ((uint64)u.p8[5]) << 40;
// FALLTHRU
[[fallthrough]];
case 5:
c += ((uint64)u.p8[4]) << 32;
// FALLTHRU
[[fallthrough]];
case 4:
c += u.p32[0];
break;
case 3:
c += ((uint64)u.p8[2]) << 16;
// FALLTHRU
[[fallthrough]];
case 2:
c += ((uint64)u.p8[1]) << 8;
// FALLTHRU
[[fallthrough]];
case 1:
c += (uint64)u.p8[0];
break;
Expand Down

0 comments on commit d1c90ce

Please sign in to comment.