From 64e76e7b58b703f2017a6de27c8b3b2475dd17e2 Mon Sep 17 00:00:00 2001 From: Zach Laine Date: Thu, 29 Feb 2024 21:17:21 -0600 Subject: [PATCH] GCC warning mitigation. --- example/self_filling_symbol_table.cpp | 1 + include/boost/parser/parser.hpp | 31 ++++++++++++++------------- test/no_case.cpp | 3 +++ test/parser_api.cpp | 2 ++ test/search.cpp | 1 + 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/example/self_filling_symbol_table.cpp b/example/self_filling_symbol_table.cpp index 3e87af47..64b1dec0 100644 --- a/example/self_filling_symbol_table.cpp +++ b/example/self_filling_symbol_table.cpp @@ -35,6 +35,7 @@ int main() auto const result = parse("X 9 X", parser, bp::ws); assert(result && *result == 9); //] + (void)result; //[ self_filling_symbol_table_after_parse assert(!parse("X", symbols)); diff --git a/include/boost/parser/parser.hpp b/include/boost/parser/parser.hpp index 1df327b2..87c3ed94 100644 --- a/include/boost/parser/parser.hpp +++ b/include/boost/parser/parser.hpp @@ -2844,7 +2844,7 @@ namespace boost { namespace parser { for (int64_t end = detail::resolve(context, min_); count != end; ++count) { detail::skip(first, last, skip, flags); - attr_t attr; + attr_t attr{}; parser_.call( use_cbs, first, @@ -2892,7 +2892,7 @@ namespace boost { namespace parser { } detail::skip(first, last, skip, flags); - attr_t attr; + attr_t attr{}; parser_.call( use_cbs, first, @@ -3154,7 +3154,7 @@ namespace boost { namespace parser { // nope if unwrapped_types is empty. using result_t = detail::to_hana_tuple_or_type_t; - result_t retval; + result_t retval{}; call(use_cbs, first, last, context, skip, flags, success, retval); return retval; } @@ -3708,7 +3708,8 @@ namespace boost { namespace parser { auto temp_result = make_temp_result( use_cbs, first, last, context, skip, flags, success); - std::decay_t{}))> retval; + std::decay_t{}))> + retval{}; auto _ = detail::scoped_trace( *this, @@ -3820,7 +3821,7 @@ namespace boost { namespace parser { 0 < max_index_t::value && detail::is_constructible_from_tuple_v< Attribute, temp_result_attr_t>) { - temp_result_attr_t temp_retval; + temp_result_attr_t temp_retval{}; call_impl( use_cbs, first, @@ -3841,7 +3842,7 @@ namespace boost { namespace parser { } } else { // call_impl requires a tuple, so we must wrap this scalar. - tuple temp_retval; + tuple temp_retval{}; call_impl( use_cbs, first, @@ -4702,7 +4703,7 @@ namespace boost { namespace parser { detail::flags flags, bool & success) const { - T retval; + T retval{}; call(use_cbs, first, last, context, skip, flags, success, retval); return retval; } @@ -5968,7 +5969,7 @@ namespace boost { namespace parser { detail::flags flags, bool & success) const -> attribute_type { - attribute_type retval; + attribute_type retval{}; call(use_cbs, first, last, context, skip, flags, success, retval); return retval; } @@ -6136,7 +6137,7 @@ namespace boost { namespace parser { detail::flags flags, bool & success) const -> attribute_type { - attribute_type retval; + attribute_type retval{}; call(use_cbs, first, last, context, skip, flags, success, retval); return retval; } @@ -6288,7 +6289,7 @@ namespace boost { namespace parser { detail::flags flags, bool & success) const -> attribute_type { - attribute_type retval; + attribute_type retval{}; call(use_cbs, first, last, context, skip, flags, success, retval); return retval; } @@ -6372,7 +6373,7 @@ namespace boost { namespace parser { detail::flags flags, bool & success) const -> attribute_type { - attribute_type retval; + attribute_type retval{}; call(use_cbs, first, last, context, skip, flags, success, retval); return retval; } @@ -6773,7 +6774,7 @@ namespace boost { namespace parser { detail::flags flags, bool & success) const { - bool retval; + bool retval{}; call(use_cbs, first, last, context, skip, flags, success, retval); return retval; } @@ -6858,7 +6859,7 @@ namespace boost { namespace parser { detail::flags flags, bool & success) const { - T retval; + T retval{}; call(use_cbs, first, last, context, skip, flags, success, retval); return retval; } @@ -6970,7 +6971,7 @@ namespace boost { namespace parser { detail::flags flags, bool & success) const { - T retval; + T retval{}; call(use_cbs, first, last, context, skip, flags, success, retval); return retval; } @@ -7058,7 +7059,7 @@ namespace boost { namespace parser { detail::flags flags, bool & success) const { - T retval; + T retval = 0; call(use_cbs, first, last, context, skip, flags, success, retval); return retval; } diff --git a/test/no_case.cpp b/test/no_case.cpp index 3ba51842..47599531 100644 --- a/test/no_case.cpp +++ b/test/no_case.cpp @@ -23,6 +23,9 @@ TEST(no_case, doc_example) auto const alpha_parser = bp::no_case[bp::char_('a', 'z')]; assert(bp::parse("a" | bp::as_utf32, bp::no_case[alpha_parser])); // Match! assert(bp::parse("B" | bp::as_utf32, bp::no_case[alpha_parser])); // Match! + + (void)street_parser; + (void)alpha_parser; } diff --git a/test/parser_api.cpp b/test/parser_api.cpp index d11b4ece..0b975087 100644 --- a/test/parser_api.cpp +++ b/test/parser_api.cpp @@ -1998,6 +1998,7 @@ TEST(parser, attr_out_param_compat) using namespace bp::literals; assert(success); + (void)success; assert(bp::get(result, 0_c) == std::vector({'r', U'ô', 'l', 'e'})); assert(bp::get(result, 1_c) == "foo"); } @@ -2015,6 +2016,7 @@ TEST(parser, attr_out_param_compat) using namespace bp::literals; assert(success); + (void)success; // The 4 code points "rôle" get transcoded to 5 UTF-8 code points to fit in the std::string. assert(bp::get(result, 0_c) == std::vector({'r', (char)0xc3, (char)0xb4, 'l', 'e'})); assert(bp::get(result, 1_c) == "foo"); diff --git a/test/search.cpp b/test/search.cpp index 1696965f..192f29f0 100644 --- a/test/search.cpp +++ b/test/search.cpp @@ -739,6 +739,7 @@ TEST(search, doc_examples) assert( std::string_view(result.begin(), result.end() - result.begin()) == "XYZ"); + (void)result; } { auto r = "XYZaaXYZbaabaXYZXYZ" | bp::search_all(bp::lit("XYZ"));