From d698b6bf262610732d7a9c956d1c29620e0f4e15 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Wed, 13 Oct 2021 22:22:05 +0200 Subject: [PATCH] :mute: silence -Weffc++ warning error: 'FooBar::foo' should be initialized in the member initialization list [-Werror=effc++] --- include/nlohmann/json.hpp | 8 ++++++++ single_include/nlohmann/json.hpp | 8 ++++++++ test/src/unit-regression2.cpp | 3 --- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 40569bb85..269ee680a 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3069,8 +3069,16 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ValueType get_impl(detail::priority_tag<0> /*unused*/) const noexcept(noexcept( JSONSerializer::from_json(std::declval(), std::declval()))) { +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#endif // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init): see https://github.com/nlohmann/json/issues/3077 ValueType ret; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + JSONSerializer::from_json(*this, ret); return ret; } diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 09db75fda..8ca12791c 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -20556,8 +20556,16 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ValueType get_impl(detail::priority_tag<0> /*unused*/) const noexcept(noexcept( JSONSerializer::from_json(std::declval(), std::declval()))) { +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Weffc++" +#endif // NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init,hicpp-member-init): see https://github.com/nlohmann/json/issues/3077 ValueType ret; +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif + JSONSerializer::from_json(*this, ret); return ret; } diff --git a/test/src/unit-regression2.cpp b/test/src/unit-regression2.cpp index b46cc5c76..4243cc609 100644 --- a/test/src/unit-regression2.cpp +++ b/test/src/unit-regression2.cpp @@ -727,10 +727,7 @@ TEST_CASE("regression tests 2") json j; j[0]["value"] = true; std::vector foo; - DOCTEST_GCC_SUPPRESS_WARNING_PUSH - DOCTEST_GCC_SUPPRESS_WARNING(-Weffc++) j.get_to(foo); - DOCTEST_GCC_SUPPRESS_WARNING_POP } }