diff --git a/include/nlohmann/detail/conversions/to_chars.hpp b/include/nlohmann/detail/conversions/to_chars.hpp index 70fb9b933..1b3d0c704 100644 --- a/include/nlohmann/detail/conversions/to_chars.hpp +++ b/include/nlohmann/detail/conversions/to_chars.hpp @@ -1074,9 +1074,9 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '-'; } + JSON_HEDLEY_DIAGNOSTIC_PUSH #ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" + JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif if (value == 0) // +-0 { @@ -1086,9 +1086,7 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '0'; return first; } -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + JSON_HEDLEY_DIAGNOSTIC_POP JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp index cb87bb93e..d93d8d71e 100644 --- a/include/nlohmann/detail/exceptions.hpp +++ b/include/nlohmann/detail/exceptions.hpp @@ -32,9 +32,9 @@ // functions to. As a result, we suppress this warning here to avoid client // code stumbling over this. See https://github.com/nlohmann/json/issues/4087 // for a discussion. +JSON_HEDLEY_DIAGNOSTIC_PUSH #if defined(__clang__) - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wweak-vtables" + JSON_HEDLEY_PRAGMA(clang diagnostic ignored "-Wweak-vtables") #endif NLOHMANN_JSON_NAMESPACE_BEGIN @@ -286,6 +286,4 @@ class other_error : public exception } // namespace detail NLOHMANN_JSON_NAMESPACE_END -#if defined(__clang__) - #pragma clang diagnostic pop -#endif +JSON_HEDLEY_DIAGNOSTIC_POP diff --git a/include/nlohmann/detail/iterators/iteration_proxy.hpp b/include/nlohmann/detail/iterators/iteration_proxy.hpp index 99246d120..5bae6c7ed 100644 --- a/include/nlohmann/detail/iterators/iteration_proxy.hpp +++ b/include/nlohmann/detail/iterators/iteration_proxy.hpp @@ -18,6 +18,7 @@ #endif #include +#include #include #include #include @@ -206,10 +207,10 @@ NLOHMANN_JSON_NAMESPACE_END namespace std { +// Fix: https://github.com/nlohmann/json/issues/1401 +JSON_HEDLEY_DIAGNOSTIC_PUSH #if defined(__clang__) - // Fix: https://github.com/nlohmann/json/issues/1401 - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wmismatched-tags" + JSON_HEDLEY_PRAGMA(clang diagnostic ignored "-Wmismatched-tags") #endif template class tuple_size<::nlohmann::detail::iteration_proxy_value> // NOLINT(cert-dcl58-cpp) @@ -223,9 +224,7 @@ class tuple_element> get(std::declval < ::nlohmann::detail::iteration_proxy_value> ())); }; -#if defined(__clang__) - #pragma clang diagnostic pop -#endif +JSON_HEDLEY_DIAGNOSTIC_POP } // namespace std diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index b8e9efa45..7875c63b2 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -1849,9 +1849,9 @@ class binary_writer void write_compact_float(const number_float_t n, detail::input_format_t format) { + JSON_HEDLEY_DIAGNOSTIC_PUSH #ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" + JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif if (!std::isfinite(n) || ((static_cast(n) >= static_cast(std::numeric_limits::lowest()) && static_cast(n) <= static_cast((std::numeric_limits::max)()) && @@ -1869,9 +1869,7 @@ class binary_writer : get_msgpack_float_prefix(n)); write_number(n); } -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + JSON_HEDLEY_DIAGNOSTIC_POP } public: diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index be4ccb90f..2937be3fe 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3769,15 +3769,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ bool operator==(const_reference rhs) const noexcept { + JSON_HEDLEY_DIAGNOSTIC_PUSH #ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" + JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif const_reference lhs = *this; JSON_IMPLEMENT_OPERATOR( ==, true, false, false) -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + JSON_HEDLEY_DIAGNOSTIC_POP } /// @brief comparison: equal @@ -3862,14 +3860,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ friend bool operator==(const_reference lhs, const_reference rhs) noexcept { + JSON_HEDLEY_DIAGNOSTIC_PUSH #ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" + JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif JSON_IMPLEMENT_OPERATOR( ==, true, false, false) -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + JSON_HEDLEY_DIAGNOSTIC_POP } /// @brief comparison: equal diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 3ce096a44..a76608f9f 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4944,9 +4944,9 @@ NLOHMANN_JSON_NAMESPACE_END // functions to. As a result, we suppress this warning here to avoid client // code stumbling over this. See https://github.com/nlohmann/json/issues/4087 // for a discussion. +JSON_HEDLEY_DIAGNOSTIC_PUSH #if defined(__clang__) - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wweak-vtables" + JSON_HEDLEY_PRAGMA(clang diagnostic ignored "-Wweak-vtables") #endif NLOHMANN_JSON_NAMESPACE_BEGIN @@ -5198,9 +5198,7 @@ class other_error : public exception } // namespace detail NLOHMANN_JSON_NAMESPACE_END -#if defined(__clang__) - #pragma clang diagnostic pop -#endif +JSON_HEDLEY_DIAGNOSTIC_POP // #include @@ -5975,6 +5973,8 @@ NLOHMANN_JSON_NAMESPACE_END // #include +// #include + // #include // #include @@ -6204,10 +6204,10 @@ NLOHMANN_JSON_NAMESPACE_END namespace std { +// Fix: https://github.com/nlohmann/json/issues/1401 +JSON_HEDLEY_DIAGNOSTIC_PUSH #if defined(__clang__) - // Fix: https://github.com/nlohmann/json/issues/1401 - #pragma clang diagnostic push - #pragma clang diagnostic ignored "-Wmismatched-tags" + JSON_HEDLEY_PRAGMA(clang diagnostic ignored "-Wmismatched-tags") #endif template class tuple_size<::nlohmann::detail::iteration_proxy_value> // NOLINT(cert-dcl58-cpp) @@ -6221,9 +6221,7 @@ class tuple_element> get(std::declval < ::nlohmann::detail::iteration_proxy_value> ())); }; -#if defined(__clang__) - #pragma clang diagnostic pop -#endif +JSON_HEDLEY_DIAGNOSTIC_POP } // namespace std @@ -18857,9 +18855,9 @@ class binary_writer void write_compact_float(const number_float_t n, detail::input_format_t format) { + JSON_HEDLEY_DIAGNOSTIC_PUSH #ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" + JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif if (!std::isfinite(n) || ((static_cast(n) >= static_cast(std::numeric_limits::lowest()) && static_cast(n) <= static_cast((std::numeric_limits::max)()) && @@ -18877,9 +18875,7 @@ class binary_writer : get_msgpack_float_prefix(n)); write_number(n); } -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + JSON_HEDLEY_DIAGNOSTIC_POP } public: @@ -20052,9 +20048,9 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '-'; } + JSON_HEDLEY_DIAGNOSTIC_PUSH #ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" + JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif if (value == 0) // +-0 { @@ -20064,9 +20060,7 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '0'; return first; } -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + JSON_HEDLEY_DIAGNOSTIC_POP JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); @@ -25197,15 +25191,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ bool operator==(const_reference rhs) const noexcept { + JSON_HEDLEY_DIAGNOSTIC_PUSH #ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" + JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif const_reference lhs = *this; JSON_IMPLEMENT_OPERATOR( ==, true, false, false) -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + JSON_HEDLEY_DIAGNOSTIC_POP } /// @brief comparison: equal @@ -25290,14 +25282,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @sa https://json.nlohmann.me/api/basic_json/operator_eq/ friend bool operator==(const_reference lhs, const_reference rhs) noexcept { + JSON_HEDLEY_DIAGNOSTIC_PUSH #ifdef __GNUC__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wfloat-equal" + JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif JSON_IMPLEMENT_OPERATOR( ==, true, false, false) -#ifdef __GNUC__ -#pragma GCC diagnostic pop -#endif + JSON_HEDLEY_DIAGNOSTIC_POP } /// @brief comparison: equal