diff --git a/include/luaconf.h b/include/luaconf.h index 95c9d23..d8e2cfd 100644 --- a/include/luaconf.h +++ b/include/luaconf.h @@ -210,6 +210,8 @@ */ #if defined(__GNUC__) || defined(__clang__) #define LUA_NORETURN __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define LUA_NORETURN __declspec(noreturn) #else #define LUA_NORETURN #endif diff --git a/src/lapi.c b/src/lapi.c index 118ccee..8507a38 100644 --- a/src/lapi.c +++ b/src/lapi.c @@ -966,7 +966,6 @@ LUA_API int lua_error (lua_State *L) { api_checknelems(L, 1); luaG_errormsg(L); lua_unlock(L); - return 0; /* to avoid warnings */ } diff --git a/src/ldebug.c b/src/ldebug.c index 6fe931a..ef9eb61 100644 --- a/src/ldebug.c +++ b/src/ldebug.c @@ -613,7 +613,7 @@ void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { } -int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { +void luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { const char *t1 = luaT_typenames[ttype(p1)]; const char *t2 = luaT_typenames[ttype(p2)]; if (t1[2] == t2[2]) diff --git a/src/ldebug.h b/src/ldebug.h index e232684..e0ed5cb 100644 --- a/src/ldebug.h +++ b/src/ldebug.h @@ -18,12 +18,12 @@ #define resethookcount(L) (L->hookcount = L->basehookcount) -LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o, const char *opname) LUA_NORETURN; -LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2) LUA_NORETURN; -LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) LUA_NORETURN; -LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) LUA_NORETURN; -LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...) LUA_NORETURN; -LUAI_FUNC void luaG_errormsg (lua_State *L) LUA_NORETURN; +LUAI_FUNC LUA_NORETURN void luaG_typeerror (lua_State *L, const TValue *o, const char *opname); +LUAI_FUNC LUA_NORETURN void luaG_concaterror (lua_State *L, StkId p1, StkId p2); +LUAI_FUNC LUA_NORETURN void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2); +LUAI_FUNC LUA_NORETURN void luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2); +LUAI_FUNC LUA_NORETURN void luaG_runerror (lua_State *L, const char *fmt, ...); +LUAI_FUNC LUA_NORETURN void luaG_errormsg (lua_State *L); LUAI_FUNC int luaG_checkcode (const Proto *pt); LUAI_FUNC int luaG_checkopenop (Instruction i); diff --git a/src/ldo.h b/src/ldo.h index 11b1d67..c421dc7 100644 --- a/src/ldo.h +++ b/src/ldo.h @@ -48,7 +48,7 @@ LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); LUAI_FUNC void luaD_growstack (lua_State *L, int n); -LUAI_FUNC void luaD_throw (lua_State *L, int errcode) LUA_NORETURN; +LUAI_FUNC LUA_NORETURN void luaD_throw (lua_State *L, int errcode); LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); LUAI_FUNC void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop); diff --git a/src/llex.h b/src/llex.h index 8226982..a5c4f44 100644 --- a/src/llex.h +++ b/src/llex.h @@ -73,8 +73,8 @@ LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); LUAI_FUNC void luaX_next (LexState *ls); LUAI_FUNC void luaX_lookahead (LexState *ls); -LUAI_FUNC void luaX_lexerror (LexState *ls, const char *msg, int token) LUA_NORETURN; -LUAI_FUNC void luaX_syntaxerror (LexState *ls, const char *s) LUA_NORETURN; +LUAI_FUNC LUA_NORETURN void luaX_lexerror (LexState *ls, const char *msg, int token); +LUAI_FUNC LUA_NORETURN void luaX_syntaxerror (LexState *ls, const char *s); LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); diff --git a/src/lmem.c b/src/lmem.c index ae7d8c9..fbc4cda 100644 --- a/src/lmem.c +++ b/src/lmem.c @@ -65,7 +65,6 @@ void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, void *luaM_toobig (lua_State *L) { luaG_runerror(L, "memory allocation error: block too big"); - return NULL; /* to avoid warnings */ } diff --git a/src/ltable.c b/src/ltable.c index 29ce0f5..cc32bcf 100644 --- a/src/ltable.c +++ b/src/ltable.c @@ -154,7 +154,6 @@ static int findindex (lua_State *L, Table *t, StkId key) { else n = gnext(n); } while (n); luaG_runerror(L, "invalid key to " LUA_QL("next")); /* key not found */ - return 0; /* to avoid warnings */ } } diff --git a/src/lvm.c b/src/lvm.c index b4bd39f..0d02768 100644 --- a/src/lvm.c +++ b/src/lvm.c @@ -235,21 +235,21 @@ static int l_strcmp (const TString *ls, const TString *rs) { int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { int res; if (ttype(l) != ttype(r)) - return luaG_ordererror(L, l, r); + luaG_ordererror(L, l, r); else if (ttisnumber(l)) return luai_numlt(nvalue(l), nvalue(r)); else if (ttisstring(l)) return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) return res; - return luaG_ordererror(L, l, r); + luaG_ordererror(L, l, r); } static int lessequal (lua_State *L, const TValue *l, const TValue *r) { int res; if (ttype(l) != ttype(r)) - return luaG_ordererror(L, l, r); + luaG_ordererror(L, l, r); else if (ttisnumber(l)) return luai_numle(nvalue(l), nvalue(r)); else if (ttisstring(l)) @@ -258,7 +258,7 @@ static int lessequal (lua_State *L, const TValue *l, const TValue *r) { return res; else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */ return !res; - return luaG_ordererror(L, l, r); + luaG_ordererror(L, l, r); }