Skip to content

Commit

Permalink
πŸ›  Clean up old VC++ code
Browse files Browse the repository at this point in the history
β€” πŸ”Ž Silence uninitialized warning for later inspection
  • Loading branch information
ShepherdSoasis authored and ThePhD committed Jun 24, 2022
1 parent 323c3ca commit 3b97af0
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 41 deletions.
9 changes: 9 additions & 0 deletions include/sol/protected_function_result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>;
Expand Down Expand Up @@ -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));
}
Expand Down
9 changes: 9 additions & 0 deletions include/sol/stack_check_get_qualified.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 2 additions & 12 deletions include/sol/stack_core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,6 @@ namespace sol {
}
else {
unqualified_getter<Tu> g {};
(void)g;
return g.get(L, index, tracking);
}
}
Expand All @@ -721,7 +720,6 @@ namespace sol {
}
else {
qualified_getter<T> g {};
(void)g;
return g.get(L, index, tracking);
}
}
Expand Down Expand Up @@ -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)...);
}
}
Expand All @@ -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)...);
}
}
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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);
}
}
Expand Down Expand Up @@ -1065,7 +1057,6 @@ namespace sol {
}
else {
unqualified_check_getter<Tu> cg {};
(void)cg;
return cg.get(L, index, std::forward<Handler>(handler), tracking);
}
}
Expand All @@ -1089,7 +1080,6 @@ namespace sol {
}
else {
qualified_check_getter<T> cg {};
(void)cg;
return cg.get(L, index, std::forward<Handler>(handler), tracking);
}
}
Expand Down
36 changes: 9 additions & 27 deletions include/sol/stack_get_unqualified.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -933,39 +927,31 @@ 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);
}
};

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);
}
};

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);
}
};

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);
}
};
Expand All @@ -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
}
Expand Down
2 changes: 0 additions & 2 deletions include/sol/stack_push.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
};
Expand Down
3 changes: 3 additions & 0 deletions include/sol/usertype_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 3b97af0

Please sign in to comment.