From c4e21ba91a477e58f0c94029f48653357df8503a Mon Sep 17 00:00:00 2001 From: Florian Albrechtskirchinger Date: Mon, 1 Aug 2022 09:55:14 +0200 Subject: [PATCH] Silence warning about hidden global declaration --- tests/src/unit-noexcept.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/tests/src/unit-noexcept.cpp b/tests/src/unit-noexcept.cpp index 6ccf6c432..d2ad27061 100644 --- a/tests/src/unit-noexcept.cpp +++ b/tests/src/unit-noexcept.cpp @@ -34,20 +34,18 @@ void to_json(json& /*unused*/, pod_bis /*unused*/) {} void from_json(const json& /*unused*/, pod /*unused*/) noexcept {} void from_json(const json& /*unused*/, pod_bis /*unused*/) {} -json* j = nullptr; - static_assert(noexcept(json{}), ""); -static_assert(noexcept(nlohmann::to_json(*j, 2)), ""); -static_assert(noexcept(nlohmann::to_json(*j, 2.5)), ""); -static_assert(noexcept(nlohmann::to_json(*j, true)), ""); -static_assert(noexcept(nlohmann::to_json(*j, test{})), ""); -static_assert(noexcept(nlohmann::to_json(*j, pod{})), ""); -static_assert(!noexcept(nlohmann::to_json(*j, pod_bis{})), ""); +static_assert(noexcept(nlohmann::to_json(std::declval(), 2)), ""); +static_assert(noexcept(nlohmann::to_json(std::declval(), 2.5)), ""); +static_assert(noexcept(nlohmann::to_json(std::declval(), true)), ""); +static_assert(noexcept(nlohmann::to_json(std::declval(), test{})), ""); +static_assert(noexcept(nlohmann::to_json(std::declval(), pod{})), ""); +static_assert(!noexcept(nlohmann::to_json(std::declval(), pod_bis{})), ""); static_assert(noexcept(json(2)), ""); static_assert(noexcept(json(test{})), ""); static_assert(noexcept(json(pod{})), ""); -static_assert(noexcept(j->get()), ""); -static_assert(!noexcept(j->get()), ""); +static_assert(noexcept(std::declval().get()), ""); +static_assert(!noexcept(std::declval().get()), ""); static_assert(noexcept(json(pod{})), ""); } // namespace @@ -70,7 +68,6 @@ TEST_CASE("runtime checks") SECTION("silence -Wunneeded-internal-declaration errors") { - j = nullptr; json j2; to_json(j2, pod()); to_json(j2, pod_bis());