Skip to content

Commit 3e0340f

Browse files
committed
mark lua error functions as noreturn
1 parent e435386 commit 3e0340f

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

CvGameCoreDLL_Expansion2/Lua/CvLuaPlayer.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -1473,7 +1473,6 @@ static DomainTypes LuaToTradeDomain(lua_State* L, int index)
14731473
return eDomain;
14741474
default:
14751475
luaL_error(L, "Invalid trade domain index %d", iDomain);
1476-
UNREACHABLE();
14771476
}
14781477
}
14791478

@@ -9391,7 +9390,6 @@ int CvLuaPlayer::lGetPlayerColors(lua_State* L)
93919390
if(pkPlayerColor == NULL)
93929391
{
93939392
luaL_error(L, "Could not find player color at row %d", eColor);
9394-
return 0;
93959393
}
93969394

93979395
const ColorTypes ePrimaryColor = (ColorTypes)pkPlayerColor->GetColorTypePrimary();
@@ -9401,15 +9399,13 @@ int CvLuaPlayer::lGetPlayerColors(lua_State* L)
94019399
if(pkPrimaryColor == NULL)
94029400
{
94039401
luaL_error(L, "Could not find primary color at row %d", ePrimaryColor);
9404-
return 0;
94059402
}
94069403
const CvColorA& kPrimaryColor = pkPrimaryColor->GetColor();
94079404

94089405
CvColorInfo* pkSecondaryColor = GC.GetColorInfo(eSecondaryColor);
94099406
if(pkSecondaryColor == NULL)
94109407
{
94119408
luaL_error(L, "Could not find secondary color at row %d", eSecondaryColor);
9412-
return 0;
94139409
}
94149410
const CvColorA& kSecondaryColor = pkSecondaryColor->GetColor();
94159411

@@ -9529,7 +9525,6 @@ int CvLuaPlayer::lGetIncomingUnitType(lua_State* L)
95299525
else
95309526
{
95319527
luaL_error(L, "Player index %d is not a valid major civilization index.", static_cast<lua_Integer>(eFromPlayer));
9532-
return 0;
95339528
}
95349529
}
95359530
}
@@ -9558,7 +9553,6 @@ int CvLuaPlayer::lGetIncomingUnitCountdown(lua_State* L)
95589553
else
95599554
{
95609555
luaL_error(L, "Player index %d is not a valid major civilization index.", static_cast<lua_Integer>(eFromPlayer));
9561-
return 0;
95629556
}
95639557
}
95649558
}

ThirdPartyLibs/Lua51/include/lauxlib.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ LUALIB_API int (luaL_newmetatable) (lua_State *L, const char *tname);
6666
LUALIB_API void *(luaL_checkudata) (lua_State *L, int ud, const char *tname);
6767

6868
LUALIB_API void (luaL_where) (lua_State *L, int lvl);
69-
LUALIB_API int (luaL_error) (lua_State *L, const char *fmt, ...);
69+
LUALIB_API LUA_NORETURN int (luaL_error) (lua_State *L, const char *fmt, ...);
7070

7171
LUALIB_API int (luaL_checkoption) (lua_State *L, int narg, const char *def,
7272
const char *const lst[]);

ThirdPartyLibs/Lua51/include/lua.h

+12-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@
1515

1616
#include "luaconf.h"
1717

18+
// Added for Vox Populi.
19+
//
20+
// Certain Lua functions are documented as not returning and it's desirable
21+
// that be reflected in the function declarations so that the compiler is
22+
// able to recognize unreachable code.
23+
#ifdef _MSC_VER
24+
#define LUA_NORETURN __declspec(noreturn)
25+
#else
26+
#define LUA_NORETURN [[noreturn]]
27+
#endif // _MSC_VER
28+
1829

1930
#define LUA_VERSION "Lua 5.1"
2031
#define LUA_RELEASE "Lua 5.1.4"
@@ -234,7 +245,7 @@ LUA_API int (lua_gc) (lua_State *L, int what, int data);
234245
** miscellaneous functions
235246
*/
236247

237-
LUA_API int (lua_error) (lua_State *L);
248+
LUA_API LUA_NORETURN int (lua_error) (lua_State *L);
238249

239250
LUA_API int (lua_next) (lua_State *L, int idx);
240251

0 commit comments

Comments
 (0)