diff --git a/include/nlohmann/detail/conversions/to_chars.hpp b/include/nlohmann/detail/conversions/to_chars.hpp index 1b3d0c704..c0945ab9e 100644 --- a/include/nlohmann/detail/conversions/to_chars.hpp +++ b/include/nlohmann/detail/conversions/to_chars.hpp @@ -1074,8 +1074,8 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '-'; } - JSON_HEDLEY_DIAGNOSTIC_PUSH #ifdef __GNUC__ + JSON_HEDLEY_DIAGNOSTIC_PUSH JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif if (value == 0) // +-0 @@ -1086,7 +1086,9 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '0'; return first; } +#ifdef __GNUC__ JSON_HEDLEY_DIAGNOSTIC_POP +#endif JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); diff --git a/include/nlohmann/detail/exceptions.hpp b/include/nlohmann/detail/exceptions.hpp index d93d8d71e..3e5b45101 100644 --- a/include/nlohmann/detail/exceptions.hpp +++ b/include/nlohmann/detail/exceptions.hpp @@ -32,8 +32,8 @@ // 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__) + JSON_HEDLEY_DIAGNOSTIC_PUSH JSON_HEDLEY_PRAGMA(clang diagnostic ignored "-Wweak-vtables") #endif @@ -286,4 +286,6 @@ class other_error : public exception } // namespace detail NLOHMANN_JSON_NAMESPACE_END -JSON_HEDLEY_DIAGNOSTIC_POP +#if defined(__clang__) + JSON_HEDLEY_DIAGNOSTIC_POP +#endif diff --git a/include/nlohmann/detail/iterators/iteration_proxy.hpp b/include/nlohmann/detail/iterators/iteration_proxy.hpp index 5bae6c7ed..c8aa50dd2 100644 --- a/include/nlohmann/detail/iterators/iteration_proxy.hpp +++ b/include/nlohmann/detail/iterators/iteration_proxy.hpp @@ -208,8 +208,8 @@ namespace std { // Fix: https://github.com/nlohmann/json/issues/1401 -JSON_HEDLEY_DIAGNOSTIC_PUSH #if defined(__clang__) + JSON_HEDLEY_DIAGNOSTIC_PUSH JSON_HEDLEY_PRAGMA(clang diagnostic ignored "-Wmismatched-tags") #endif template @@ -224,7 +224,9 @@ class tuple_element> get(std::declval < ::nlohmann::detail::iteration_proxy_value> ())); }; -JSON_HEDLEY_DIAGNOSTIC_POP +#if defined(__clang__) + JSON_HEDLEY_DIAGNOSTIC_POP +#endif } // namespace std diff --git a/include/nlohmann/detail/output/binary_writer.hpp b/include/nlohmann/detail/output/binary_writer.hpp index 7875c63b2..496c733d1 100644 --- a/include/nlohmann/detail/output/binary_writer.hpp +++ b/include/nlohmann/detail/output/binary_writer.hpp @@ -1849,8 +1849,8 @@ class binary_writer void write_compact_float(const number_float_t n, detail::input_format_t format) { - JSON_HEDLEY_DIAGNOSTIC_PUSH #ifdef __GNUC__ + JSON_HEDLEY_DIAGNOSTIC_PUSH JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif if (!std::isfinite(n) || ((static_cast(n) >= static_cast(std::numeric_limits::lowest()) && @@ -1869,7 +1869,9 @@ class binary_writer : get_msgpack_float_prefix(n)); write_number(n); } +#ifdef __GNUC__ JSON_HEDLEY_DIAGNOSTIC_POP +#endif } public: diff --git a/include/nlohmann/json.hpp b/include/nlohmann/json.hpp index 2937be3fe..45a89d8ce 100644 --- a/include/nlohmann/json.hpp +++ b/include/nlohmann/json.hpp @@ -3769,13 +3769,15 @@ 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__ + JSON_HEDLEY_DIAGNOSTIC_PUSH JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif const_reference lhs = *this; JSON_IMPLEMENT_OPERATOR( ==, true, false, false) +#ifdef __GNUC__ JSON_HEDLEY_DIAGNOSTIC_POP +#endif } /// @brief comparison: equal @@ -3860,12 +3862,14 @@ 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__ + JSON_HEDLEY_DIAGNOSTIC_PUSH JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif JSON_IMPLEMENT_OPERATOR( ==, true, false, false) +#ifdef __GNUC__ JSON_HEDLEY_DIAGNOSTIC_POP +#endif } /// @brief comparison: equal diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index a76608f9f..7b2fdac25 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4944,8 +4944,8 @@ 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__) + JSON_HEDLEY_DIAGNOSTIC_PUSH JSON_HEDLEY_PRAGMA(clang diagnostic ignored "-Wweak-vtables") #endif @@ -5198,7 +5198,9 @@ class other_error : public exception } // namespace detail NLOHMANN_JSON_NAMESPACE_END -JSON_HEDLEY_DIAGNOSTIC_POP +#if defined(__clang__) + JSON_HEDLEY_DIAGNOSTIC_POP +#endif // #include @@ -6205,8 +6207,8 @@ namespace std { // Fix: https://github.com/nlohmann/json/issues/1401 -JSON_HEDLEY_DIAGNOSTIC_PUSH #if defined(__clang__) + JSON_HEDLEY_DIAGNOSTIC_PUSH JSON_HEDLEY_PRAGMA(clang diagnostic ignored "-Wmismatched-tags") #endif template @@ -6221,7 +6223,9 @@ class tuple_element> get(std::declval < ::nlohmann::detail::iteration_proxy_value> ())); }; -JSON_HEDLEY_DIAGNOSTIC_POP +#if defined(__clang__) + JSON_HEDLEY_DIAGNOSTIC_POP +#endif } // namespace std @@ -18855,8 +18859,8 @@ class binary_writer void write_compact_float(const number_float_t n, detail::input_format_t format) { - JSON_HEDLEY_DIAGNOSTIC_PUSH #ifdef __GNUC__ + JSON_HEDLEY_DIAGNOSTIC_PUSH JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif if (!std::isfinite(n) || ((static_cast(n) >= static_cast(std::numeric_limits::lowest()) && @@ -18875,7 +18879,9 @@ class binary_writer : get_msgpack_float_prefix(n)); write_number(n); } +#ifdef __GNUC__ JSON_HEDLEY_DIAGNOSTIC_POP +#endif } public: @@ -20048,8 +20054,8 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '-'; } - JSON_HEDLEY_DIAGNOSTIC_PUSH #ifdef __GNUC__ + JSON_HEDLEY_DIAGNOSTIC_PUSH JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif if (value == 0) // +-0 @@ -20060,7 +20066,9 @@ char* to_chars(char* first, const char* last, FloatType value) *first++ = '0'; return first; } +#ifdef __GNUC__ JSON_HEDLEY_DIAGNOSTIC_POP +#endif JSON_ASSERT(last - first >= std::numeric_limits::max_digits10); @@ -25191,13 +25199,15 @@ 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__ + JSON_HEDLEY_DIAGNOSTIC_PUSH JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif const_reference lhs = *this; JSON_IMPLEMENT_OPERATOR( ==, true, false, false) +#ifdef __GNUC__ JSON_HEDLEY_DIAGNOSTIC_POP +#endif } /// @brief comparison: equal @@ -25282,12 +25292,14 @@ 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__ + JSON_HEDLEY_DIAGNOSTIC_PUSH JSON_HEDLEY_PRAGMA(GCC diagnostic ignored "-Wfloat-equal") #endif JSON_IMPLEMENT_OPERATOR( ==, true, false, false) +#ifdef __GNUC__ JSON_HEDLEY_DIAGNOSTIC_POP +#endif } /// @brief comparison: equal