Skip to content

Commit

Permalink
LUA: Use the XOREOS_FALLTHROUGH macro to mark fallthroughs
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed May 25, 2018
1 parent f037649 commit 9b85848
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 4 additions & 2 deletions lua/ldebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#define ldebug_c

#include "src/common/fallthrough.h"

#include "lua.h"

#include "lapi.h"
Expand Down Expand Up @@ -376,10 +378,10 @@ static Instruction luaG_symbexec (const Proto *pt, int lastpc, int reg) {
case OP_TFORLOOP:
checkreg(pt, a+c+5);
if (reg >= a) last = pc; /* affect all registers above base */
// Fallthrough
XOREOS_FALLTHROUGH;
case OP_FORLOOP:
checkreg(pt, a+2);
// Fallthrough
XOREOS_FALLTHROUGH;
case OP_JMP: {
int dest = pc+1+b;
check(0 <= dest && dest < pt->sizecode);
Expand Down
4 changes: 3 additions & 1 deletion lua/lstrlib.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

#define lstrlib_c

#include "src/common/fallthrough.h"

#include "lua.h"

#include "lauxlib.h"
Expand Down Expand Up @@ -731,7 +733,7 @@ static int str_format (lua_State *L) {
break;
}
}
// Fallthrough
break;
default: { /* also treat cases `pnLlh' */
return luaL_error(L, "invalid option to `format'");
}
Expand Down
4 changes: 3 additions & 1 deletion lua/ltable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@

#define ltable_c

#include "src/common/fallthrough.h"

#include "lua.h"

#include "ldebug.h"
Expand Down Expand Up @@ -476,7 +478,7 @@ const TObject *luaH_get (Table *t, const TObject *key) {
if (cast(lua_Number, k) == nvalue(key)) /* is an integer index? */
return luaH_getnum(t, k); /* use specialized version */
}
// Fallthrough
XOREOS_FALLTHROUGH;
default: return luaH_getany(t, key);
}
}
Expand Down

0 comments on commit 9b85848

Please sign in to comment.