🛠 Clean up old VC++ code

🔎 Silence uninitialized warning for later inspection
This commit is contained in:
Shepherd 2022-06-24 09:51:09 -04:00 committed by The Phantom Derpstorm
parent 323c3ca210
commit 3b97af0ac4
6 changed files with 32 additions and 41 deletions

View File

@ -99,6 +99,11 @@ namespace sol {
return status() == call_status::ok || status() == call_status::yielded;
}
#if SOL_IS_ON(SOL_COMPILER_GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
template <typename T>
decltype(auto) get(int index_offset = 0) const {
using UT = meta::unqualified_t<T>;
@ -140,6 +145,10 @@ namespace sol {
}
}
#if SOL_IS_ON(SOL_COMPILER_GCC)
#pragma GCC diagnostic pop
#endif
type get_type(int index_offset = 0) const noexcept {
return type_of(L, index + static_cast<int>(index_offset));
}

View File

@ -30,6 +30,11 @@
namespace sol { namespace stack {
#if SOL_IS_ON(SOL_COMPILER_GCC)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
namespace stack_detail {
template <typename OptionalType, typename T, typename Handler>
OptionalType get_optional(lua_State* L, int index, Handler&& handler, record& tracking) {
@ -116,6 +121,10 @@ namespace sol { namespace stack {
}
} // namespace stack_detail
#if SOL_IS_ON(SOL_COMPILER_GCC)
#pragma GCC diagnostic pop
#endif
template <typename T, typename>
struct qualified_check_getter {
typedef decltype(stack_detail::unchecked_get<T>(nullptr, -1, std::declval<record&>())) R;

View File

@ -709,7 +709,6 @@ namespace sol {
}
else {
unqualified_getter<Tu> g {};
(void)g;
return g.get(L, index, tracking);
}
}
@ -721,7 +720,6 @@ namespace sol {
}
else {
qualified_getter<T> g {};
(void)g;
return g.get(L, index, tracking);
}
}
@ -877,7 +875,6 @@ namespace sol {
}
else {
unqualified_pusher<Tu> p {};
(void)p;
return p.push(L, std::forward<T>(t), std::forward<Args>(args)...);
}
}
@ -897,7 +894,6 @@ namespace sol {
}
else {
unqualified_pusher<Tu> p {};
(void)p;
return p.push(L, std::forward<Arg>(arg), std::forward<Args>(args)...);
}
}
@ -983,9 +979,7 @@ namespace sol {
return sol_lua_check(types<Tu>(), L, index, std::forward<Handler>(handler), tracking);
}
else {
unqualified_checker<Tu, lua_type_of_v<Tu>> c;
// VC++ has a bad warning here: shut it up
(void)c;
unqualified_checker<Tu, lua_type_of_v<Tu>> c{};
return c.check(L, index, std::forward<Handler>(handler), tracking);
}
}
@ -1009,9 +1003,7 @@ namespace sol {
}
else {
using Tu = meta::unqualified_t<T>;
qualified_checker<T, lua_type_of_v<Tu>> c;
// VC++ has a bad warning here: shut it up
(void)c;
qualified_checker<T, lua_type_of_v<Tu>> c{};
return c.check(L, index, std::forward<Handler>(handler), tracking);
}
}
@ -1065,7 +1057,6 @@ namespace sol {
}
else {
unqualified_check_getter<Tu> cg {};
(void)cg;
return cg.get(L, index, std::forward<Handler>(handler), tracking);
}
}
@ -1089,7 +1080,6 @@ namespace sol {
}
else {
qualified_check_getter<T> cg {};
(void)cg;
return cg.get(L, index, std::forward<Handler>(handler), tracking);
}
}

View File

@ -581,23 +581,17 @@ namespace sol { namespace stack {
typedef typename T::value_type P;
typedef typename P::first_type K;
typedef typename P::second_type V;
unqualified_getter<as_table_t<T>> g;
// VC++ has a bad warning here: shut it up
(void)g;
unqualified_getter<as_table_t<T>> g{};
return g.get(types<K, nested<V>>(), L, index, tracking);
}
else {
typedef typename T::value_type V;
unqualified_getter<as_table_t<T>> g;
// VC++ has a bad warning here: shut it up
(void)g;
unqualified_getter<as_table_t<T>> g{};
return g.get(types<nested<V>>(), L, index, tracking);
}
}
else {
unqualified_getter<Tu> g;
// VC++ has a bad warning here: shut it up
(void)g;
unqualified_getter<Tu> g{};
return g.get(L, index, tracking);
}
}
@ -933,9 +927,7 @@ namespace sol { namespace stack {
tracking.use(1);
return nullptr;
}
unqualified_getter<detail::as_value_tag<T>> g;
// Avoid VC++ warning
(void)g;
unqualified_getter<detail::as_value_tag<T>> g{};
return g.get_no_lua_nil(L, index, tracking);
}
};
@ -943,9 +935,7 @@ namespace sol { namespace stack {
template <typename T>
struct unqualified_getter<non_null<T*>> {
static T* get(lua_State* L, int index, record& tracking) {
unqualified_getter<detail::as_value_tag<T>> g;
// Avoid VC++ warning
(void)g;
unqualified_getter<detail::as_value_tag<T>> g{};
return g.get_no_lua_nil(L, index, tracking);
}
};
@ -953,9 +943,7 @@ namespace sol { namespace stack {
template <typename T>
struct unqualified_getter<T&> {
static T& get(lua_State* L, int index, record& tracking) {
unqualified_getter<detail::as_value_tag<T>> g;
// Avoid VC++ warning
(void)g;
unqualified_getter<detail::as_value_tag<T>> g{};
return g.get(L, index, tracking);
}
};
@ -963,9 +951,7 @@ namespace sol { namespace stack {
template <typename T>
struct unqualified_getter<std::reference_wrapper<T>> {
static T& get(lua_State* L, int index, record& tracking) {
unqualified_getter<T&> g;
// Avoid VC++ warning
(void)g;
unqualified_getter<T&> g{};
return g.get(L, index, tracking);
}
};
@ -978,15 +964,11 @@ namespace sol { namespace stack {
return stack_detail::get_function_pointer<T>(L, index, tracking);
}
else {
unqualified_getter<detail::as_pointer_tag<T>> g;
// Avoid VC++ warning
(void)g;
unqualified_getter<detail::as_pointer_tag<T>> g{};
return g.get(L, index, tracking);
}
#else
unqualified_getter<detail::as_pointer_tag<T>> g;
// Avoid VC++ warning
(void)g;
unqualified_getter<detail::as_pointer_tag<T>> g{};
return g.get(L, index, tracking);
#endif
}

View File

@ -513,8 +513,6 @@ namespace sol { namespace stack {
struct unqualified_pusher<std::initializer_list<T>> {
static int push(lua_State* L, const std::initializer_list<T>& il) noexcept {
unqualified_pusher<detail::as_table_tag<std::initializer_list<T>>> p {};
// silence annoying VC++ warning
(void)p;
return p.push(L, il);
}
};

View File

@ -308,12 +308,15 @@ namespace sol { namespace u_detail {
usertype_storage_base(lua_State* L_)
: m_L(L_)
, storage()
, string_keys_storage()
, string_keys()
, auxiliary_keys(0, stateless_reference_hash(L_), stateless_reference_equals(L_))
, value_index_table()
, reference_index_table()
, unique_index_table()
, const_reference_index_table()
, const_value_index_table()
, named_index_table()
, type_table(make_reference<stateless_reference>(L_, create))
, gc_names_table(make_reference<stateless_reference>(L_, create))
, named_metatable(make_reference<stateless_reference>(L_, create))