From 3b97af0ac417c6f5ee2d16fa4c2cab2885409352 Mon Sep 17 00:00:00 2001 From: Shepherd Date: Fri, 24 Jun 2022 09:51:09 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=9B=A0=20Clean=20up=20old=20VC++=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit — 🔎 Silence uninitialized warning for later inspection --- include/sol/protected_function_result.hpp | 9 ++++++ include/sol/stack_check_get_qualified.hpp | 9 ++++++ include/sol/stack_core.hpp | 14 ++------- include/sol/stack_get_unqualified.hpp | 36 ++++++----------------- include/sol/stack_push.hpp | 2 -- include/sol/usertype_storage.hpp | 3 ++ 6 files changed, 32 insertions(+), 41 deletions(-) diff --git a/include/sol/protected_function_result.hpp b/include/sol/protected_function_result.hpp index afcbc1c2..5859a7ae 100644 --- a/include/sol/protected_function_result.hpp +++ b/include/sol/protected_function_result.hpp @@ -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 decltype(auto) get(int index_offset = 0) const { using UT = meta::unqualified_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(index_offset)); } diff --git a/include/sol/stack_check_get_qualified.hpp b/include/sol/stack_check_get_qualified.hpp index 313f7b9e..102e213e 100644 --- a/include/sol/stack_check_get_qualified.hpp +++ b/include/sol/stack_check_get_qualified.hpp @@ -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 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 struct qualified_check_getter { typedef decltype(stack_detail::unchecked_get(nullptr, -1, std::declval())) R; diff --git a/include/sol/stack_core.hpp b/include/sol/stack_core.hpp index eca4f969..4feca049 100644 --- a/include/sol/stack_core.hpp +++ b/include/sol/stack_core.hpp @@ -709,7 +709,6 @@ namespace sol { } else { unqualified_getter g {}; - (void)g; return g.get(L, index, tracking); } } @@ -721,7 +720,6 @@ namespace sol { } else { qualified_getter g {}; - (void)g; return g.get(L, index, tracking); } } @@ -877,7 +875,6 @@ namespace sol { } else { unqualified_pusher p {}; - (void)p; return p.push(L, std::forward(t), std::forward(args)...); } } @@ -897,7 +894,6 @@ namespace sol { } else { unqualified_pusher p {}; - (void)p; return p.push(L, std::forward(arg), std::forward(args)...); } } @@ -983,9 +979,7 @@ namespace sol { return sol_lua_check(types(), L, index, std::forward(handler), tracking); } else { - unqualified_checker> c; - // VC++ has a bad warning here: shut it up - (void)c; + unqualified_checker> c{}; return c.check(L, index, std::forward(handler), tracking); } } @@ -1009,9 +1003,7 @@ namespace sol { } else { using Tu = meta::unqualified_t; - qualified_checker> c; - // VC++ has a bad warning here: shut it up - (void)c; + qualified_checker> c{}; return c.check(L, index, std::forward(handler), tracking); } } @@ -1065,7 +1057,6 @@ namespace sol { } else { unqualified_check_getter cg {}; - (void)cg; return cg.get(L, index, std::forward(handler), tracking); } } @@ -1089,7 +1080,6 @@ namespace sol { } else { qualified_check_getter cg {}; - (void)cg; return cg.get(L, index, std::forward(handler), tracking); } } diff --git a/include/sol/stack_get_unqualified.hpp b/include/sol/stack_get_unqualified.hpp index b9976d93..1764089a 100644 --- a/include/sol/stack_get_unqualified.hpp +++ b/include/sol/stack_get_unqualified.hpp @@ -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> g; - // VC++ has a bad warning here: shut it up - (void)g; + unqualified_getter> g{}; return g.get(types>(), L, index, tracking); } else { typedef typename T::value_type V; - unqualified_getter> g; - // VC++ has a bad warning here: shut it up - (void)g; + unqualified_getter> g{}; return g.get(types>(), L, index, tracking); } } else { - unqualified_getter g; - // VC++ has a bad warning here: shut it up - (void)g; + unqualified_getter g{}; return g.get(L, index, tracking); } } @@ -933,9 +927,7 @@ namespace sol { namespace stack { tracking.use(1); return nullptr; } - unqualified_getter> g; - // Avoid VC++ warning - (void)g; + unqualified_getter> g{}; return g.get_no_lua_nil(L, index, tracking); } }; @@ -943,9 +935,7 @@ namespace sol { namespace stack { template struct unqualified_getter> { static T* get(lua_State* L, int index, record& tracking) { - unqualified_getter> g; - // Avoid VC++ warning - (void)g; + unqualified_getter> g{}; return g.get_no_lua_nil(L, index, tracking); } }; @@ -953,9 +943,7 @@ namespace sol { namespace stack { template struct unqualified_getter { static T& get(lua_State* L, int index, record& tracking) { - unqualified_getter> g; - // Avoid VC++ warning - (void)g; + unqualified_getter> g{}; return g.get(L, index, tracking); } }; @@ -963,9 +951,7 @@ namespace sol { namespace stack { template struct unqualified_getter> { static T& get(lua_State* L, int index, record& tracking) { - unqualified_getter g; - // Avoid VC++ warning - (void)g; + unqualified_getter g{}; return g.get(L, index, tracking); } }; @@ -978,15 +964,11 @@ namespace sol { namespace stack { return stack_detail::get_function_pointer(L, index, tracking); } else { - unqualified_getter> g; - // Avoid VC++ warning - (void)g; + unqualified_getter> g{}; return g.get(L, index, tracking); } #else - unqualified_getter> g; - // Avoid VC++ warning - (void)g; + unqualified_getter> g{}; return g.get(L, index, tracking); #endif } diff --git a/include/sol/stack_push.hpp b/include/sol/stack_push.hpp index 79a1f431..6640c0a2 100644 --- a/include/sol/stack_push.hpp +++ b/include/sol/stack_push.hpp @@ -513,8 +513,6 @@ namespace sol { namespace stack { struct unqualified_pusher> { static int push(lua_State* L, const std::initializer_list& il) noexcept { unqualified_pusher>> p {}; - // silence annoying VC++ warning - (void)p; return p.push(L, il); } }; diff --git a/include/sol/usertype_storage.hpp b/include/sol/usertype_storage.hpp index 22c2add0..9450367a 100644 --- a/include/sol/usertype_storage.hpp +++ b/include/sol/usertype_storage.hpp @@ -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(L_, create)) , gc_names_table(make_reference(L_, create)) , named_metatable(make_reference(L_, create))