diff options
author | Nat Goodspeed <nat@lindenlab.com> | 2024-02-08 11:33:59 -0500 |
---|---|---|
committer | Nat Goodspeed <nat@lindenlab.com> | 2024-02-08 11:33:59 -0500 |
commit | ef9a7813522c247763ba53bf3e3c55943e385745 (patch) | |
tree | 106a9ef697a855930e95b71c3bdb3ea4fae6b45e /indra/llcommon | |
parent | 43be64733ca667f2b117b48d9a808d0e3cf2aebc (diff) |
Defend lluau::error() from platform-specific diagnostics.
macOS clang produces fatal warnings when trying to pass a const char*
parameter to luaL_error() (-Wformat-security). Temporarily suppressing that
requires #pragma clang directives which, in turn, produce fatal warnings in
VS.
Moreover, VS recognizes that luaL_error() never returns, and so diagnoses the
following return statement as unreachable code. But that return statement is
the whole reason for lluau::error()'s existence...
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/lua_function.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/indra/llcommon/lua_function.h b/indra/llcommon/lua_function.h index ea9f2ebdf8..82cd91984a 100644 --- a/indra/llcommon/lua_function.h +++ b/indra/llcommon/lua_function.h @@ -26,15 +26,21 @@ namespace lluau { // luau defines luaL_error() as void, but we want to use the Lua idiom of // 'return error(...)'. Wrap luaL_error() in an int function. +#if __clang__ #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wformat-security" +#endif // __clang__ template<typename... Args> int error(lua_State* L, const char* format, Args&&... args) { luaL_error(L, format, std::forward<Args>(args)...); +#ifndef LL_MSVC return 0; +#endif } +#if __clang__ #pragma clang diagnostic pop +#endif // __clang__ // luau removed lua_dostring(), but since we perform the equivalent luau // sequence in multiple places, encapsulate it. desc and text are strings |