Skip to content

Commit eaafdf0

Browse files
authored
Fix a few warnings under different compilers (#267)
1 parent 82c763c commit eaafdf0

4 files changed

Lines changed: 26 additions & 6 deletions

File tree

‎Distribution/LuaBridge/LuaBridge.h‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3722,7 +3722,7 @@ class LuaException : public std::exception
37223722
return m_what.c_str();
37233723
}
37243724

3725-
static void raise(lua_State* L, std::error_code code)
3725+
[[noreturn]] static void raise(lua_State* L, std::error_code code)
37263726
{
37273727
LUABRIDGE_ASSERT(areExceptionsEnabled(L));
37283728

@@ -8613,7 +8613,6 @@ inline int newindex_metamethod(lua_State* L)
86138613

86148614
lua_pop(L, 1);
86158615
raise_lua_error(L, "no writable member '%s'", key);
8616-
return 0;
86178616
}
86188617

86198618
template <bool IsObject>
@@ -8703,7 +8702,6 @@ inline int newindex_metamethod_simple(lua_State* L)
87038702
}
87048703

87058704
raise_lua_error(L, "no writable member '%s'", key);
8706-
return 0;
87078705
}
87088706

87098707
[[noreturn]] inline int read_only_error(lua_State* L)
@@ -12967,7 +12965,9 @@ class Namespace : public detail::Registrar
1296712965
lua_pop(L, 4);
1296812966

1296912967
throw_or_assert<std::logic_error>("Base class is not registered");
12968+
#if !LUABRIDGE_HAS_EXCEPTIONS
1297012969
return;
12970+
#endif
1297112971
}
1297212972

1297312973
lua_rawgetp_x(L, -1, detail::getClassKey());
@@ -12976,7 +12976,9 @@ class Namespace : public detail::Registrar
1297612976
lua_pop(L, 5);
1297712977

1297812978
throw_or_assert<std::logic_error>("Base class is not registered");
12979+
#if !LUABRIDGE_HAS_EXCEPTIONS
1297912980
return;
12981+
#endif
1298012982
}
1298112983

1298212984
appendParentList(L, clParentsIndex, visitedIndex, -1);
@@ -13293,7 +13295,9 @@ class Namespace : public detail::Registrar
1329313295
if (name == std::string_view("__gc"))
1329413296
{
1329513297
throw_or_assert<std::logic_error>("__gc metamethod registration is forbidden");
13298+
#if !LUABRIDGE_HAS_EXCEPTIONS
1329613299
return *this;
13300+
#endif
1329713301
}
1329813302

1329913303
if constexpr (sizeof...(Functions) == 1)
@@ -14016,7 +14020,9 @@ class Namespace : public detail::Registrar
1401614020
{
1401714021
throw_or_assert<std::logic_error>("endNamespace() called on global namespace");
1401814022

14023+
#if !LUABRIDGE_HAS_EXCEPTIONS
1401914024
return Namespace(std::move(*this));
14025+
#endif
1402014026
}
1402114027

1402214028
LUABRIDGE_ASSERT(m_stackSize > 1);
@@ -14060,7 +14066,9 @@ class Namespace : public detail::Registrar
1406014066
{
1406114067
throw_or_assert<std::logic_error>("addProperty() called on global namespace");
1406214068

14069+
#if !LUABRIDGE_HAS_EXCEPTIONS
1406314070
return *this;
14071+
#endif
1406414072
}
1406514073

1406614074
detail::push_property_getter(L, std::move(getter), name);
@@ -14082,7 +14090,9 @@ class Namespace : public detail::Registrar
1408214090
{
1408314091
throw_or_assert<std::logic_error>("addProperty() called on global namespace");
1408414092

14093+
#if !LUABRIDGE_HAS_EXCEPTIONS
1408514094
return *this;
14095+
#endif
1408614096
}
1408714097

1408814098
detail::push_property_getter(L, std::move(getter), name);

‎Source/LuaBridge/detail/CFunctions.h‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,7 +1428,6 @@ inline int newindex_metamethod(lua_State* L)
14281428

14291429
lua_pop(L, 1); // Stack: -
14301430
raise_lua_error(L, "no writable member '%s'", key);
1431-
return 0;
14321431
}
14331432

14341433
template <bool IsObject>
@@ -1519,7 +1518,6 @@ inline int newindex_metamethod_simple(lua_State* L)
15191518
}
15201519

15211520
raise_lua_error(L, "no writable member '%s'", key);
1522-
return 0;
15231521
}
15241522

15251523
//=================================================================================================

‎Source/LuaBridge/detail/LuaException.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class LuaException : public std::exception
4949
/**
5050
* @brief Throw an exception or raises a luaerror when exceptions are disabled.
5151
*/
52-
static void raise(lua_State* L, std::error_code code)
52+
[[noreturn]] static void raise(lua_State* L, std::error_code code)
5353
{
5454
LUABRIDGE_ASSERT(areExceptionsEnabled(L));
5555

‎Source/LuaBridge/detail/Namespace.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,9 @@ class Namespace : public detail::Registrar
566566
lua_pop(L, 4); // pop (nil), visited, cast table, cl parents. Stack: ns, co, cl, st
567567

568568
throw_or_assert<std::logic_error>("Base class is not registered");
569+
#if !LUABRIDGE_HAS_EXCEPTIONS
569570
return;
571+
#endif
570572
}
571573

572574
lua_rawgetp_x(L, -1, detail::getClassKey()); // Stack: ..., visited, base st, base cl | nil
@@ -575,7 +577,9 @@ class Namespace : public detail::Registrar
575577
lua_pop(L, 5); // pop (nil), base st, visited, cast table, cl parents. Stack: ns, co, cl, st
576578

577579
throw_or_assert<std::logic_error>("Base class is not registered");
580+
#if !LUABRIDGE_HAS_EXCEPTIONS
578581
return;
582+
#endif
579583
}
580584

581585
appendParentList(L, clParentsIndex, visitedIndex, -1);
@@ -941,7 +945,9 @@ class Namespace : public detail::Registrar
941945
if (name == std::string_view("__gc"))
942946
{
943947
throw_or_assert<std::logic_error>("__gc metamethod registration is forbidden");
948+
#if !LUABRIDGE_HAS_EXCEPTIONS
944949
return *this;
950+
#endif
945951
}
946952

947953
if constexpr (sizeof...(Functions) == 1)
@@ -1842,7 +1848,9 @@ class Namespace : public detail::Registrar
18421848
{
18431849
throw_or_assert<std::logic_error>("endNamespace() called on global namespace");
18441850

1851+
#if !LUABRIDGE_HAS_EXCEPTIONS
18451852
return Namespace(std::move(*this));
1853+
#endif
18461854
}
18471855

18481856
LUABRIDGE_ASSERT(m_stackSize > 1);
@@ -1904,7 +1912,9 @@ class Namespace : public detail::Registrar
19041912
{
19051913
throw_or_assert<std::logic_error>("addProperty() called on global namespace");
19061914

1915+
#if !LUABRIDGE_HAS_EXCEPTIONS
19071916
return *this;
1917+
#endif
19081918
}
19091919

19101920
detail::push_property_getter(L, std::move(getter), name); // Stack: ns, getter
@@ -1935,7 +1945,9 @@ class Namespace : public detail::Registrar
19351945
{
19361946
throw_or_assert<std::logic_error>("addProperty() called on global namespace");
19371947

1948+
#if !LUABRIDGE_HAS_EXCEPTIONS
19381949
return *this;
1950+
#endif
19391951
}
19401952

19411953
detail::push_property_getter(L, std::move(getter), name); // Stack: ns, getter

0 commit comments

Comments
 (0)