forked from mpusz/mp-units
Supress "zero as null pointer constant" warning
This commit is contained in:
@@ -80,8 +80,11 @@ constexpr auto lexicographical_compare_three_way(I1 f1, I1 l1, I2 f2, I2 l2, Cmp
|
|||||||
|
|
||||||
bool exhaust1 = (f1 == l1);
|
bool exhaust1 = (f1 == l1);
|
||||||
bool exhaust2 = (f2 == l2);
|
bool exhaust2 = (f2 == l2);
|
||||||
|
UNITS_DIAGNOSTIC_PUSH
|
||||||
|
UNITS_DIAGNOSTIC_IGNORE_ZERO_AS_NULLPOINTER_CONSTANT
|
||||||
for (; !exhaust1 && !exhaust2; exhaust1 = (++f1 == l1), exhaust2 = (++f2 == l2))
|
for (; !exhaust1 && !exhaust2; exhaust1 = (++f1 == l1), exhaust2 = (++f2 == l2))
|
||||||
if (auto c = comp(*f1, *f2); c != 0) return c;
|
if (auto c = comp(*f1, *f2); c != 0) return c;
|
||||||
|
UNITS_DIAGNOSTIC_POP
|
||||||
|
|
||||||
return !exhaust1 ? std::strong_ordering::greater
|
return !exhaust1 ? std::strong_ordering::greater
|
||||||
: !exhaust2 ? std::strong_ordering::less
|
: !exhaust2 ? std::strong_ordering::less
|
||||||
|
2
src/core/include/units/bits/external/hacks.h
vendored
2
src/core/include/units/bits/external/hacks.h
vendored
@@ -51,6 +51,7 @@
|
|||||||
#define UNITS_DIAGNOSTIC_IGNORE_NON_TEMPLATE_FRIEND UNITS_DIAGNOSTIC_IGNORE("-Wnon-template-friend")
|
#define UNITS_DIAGNOSTIC_IGNORE_NON_TEMPLATE_FRIEND UNITS_DIAGNOSTIC_IGNORE("-Wnon-template-friend")
|
||||||
#define UNITS_DIAGNOSTIC_IGNORE_SHADOW UNITS_DIAGNOSTIC_IGNORE("-Wshadow")
|
#define UNITS_DIAGNOSTIC_IGNORE_SHADOW UNITS_DIAGNOSTIC_IGNORE("-Wshadow")
|
||||||
#define UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE
|
#define UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE
|
||||||
|
#define UNITS_DIAGNOSTIC_IGNORE_ZERO_AS_NULLPOINTER_CONSTANT UNITS_DIAGNOSTIC_IGNORE("-Wzero-as-nullpointer-constant")
|
||||||
#else
|
#else
|
||||||
#define UNITS_DIAGNOSTIC_PUSH UNITS_PRAGMA(warning(push))
|
#define UNITS_DIAGNOSTIC_PUSH UNITS_PRAGMA(warning(push))
|
||||||
#define UNITS_DIAGNOSTIC_POP UNITS_PRAGMA(warning(pop))
|
#define UNITS_DIAGNOSTIC_POP UNITS_PRAGMA(warning(pop))
|
||||||
@@ -63,6 +64,7 @@
|
|||||||
#define UNITS_DIAGNOSTIC_IGNORE_NON_TEMPLATE_FRIEND
|
#define UNITS_DIAGNOSTIC_IGNORE_NON_TEMPLATE_FRIEND
|
||||||
#define UNITS_DIAGNOSTIC_IGNORE_SHADOW UNITS_DIAGNOSTIC_IGNORE(4459)
|
#define UNITS_DIAGNOSTIC_IGNORE_SHADOW UNITS_DIAGNOSTIC_IGNORE(4459)
|
||||||
#define UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE UNITS_DIAGNOSTIC_IGNORE(4702)
|
#define UNITS_DIAGNOSTIC_IGNORE_UNREACHABLE UNITS_DIAGNOSTIC_IGNORE(4702)
|
||||||
|
#define UNITS_DIAGNOSTIC_IGNORE_ZERO_AS_NULLPOINTER_CONSTANT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if _LIBCPP_VERSION
|
#if _LIBCPP_VERSION
|
||||||
|
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
// IWYU pragma: begin_exports
|
// IWYU pragma: begin_exports
|
||||||
#include <units/bits/external/fixed_string.h>
|
#include <units/bits/external/fixed_string.h>
|
||||||
|
#include <units/bits/external/hacks.h>
|
||||||
#include <compare>
|
#include <compare>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
@@ -146,7 +147,10 @@ struct basic_symbol_text {
|
|||||||
[[nodiscard]] friend constexpr auto operator<=>(const basic_symbol_text& lhs,
|
[[nodiscard]] friend constexpr auto operator<=>(const basic_symbol_text& lhs,
|
||||||
const basic_symbol_text<StandardCharT2, N2, M2>& rhs) noexcept
|
const basic_symbol_text<StandardCharT2, N2, M2>& rhs) noexcept
|
||||||
{
|
{
|
||||||
|
UNITS_DIAGNOSTIC_PUSH
|
||||||
|
UNITS_DIAGNOSTIC_IGNORE_ZERO_AS_NULLPOINTER_CONSTANT
|
||||||
if (const auto cmp = lhs.standard() <=> rhs.standard(); cmp != 0) return cmp;
|
if (const auto cmp = lhs.standard() <=> rhs.standard(); cmp != 0) return cmp;
|
||||||
|
UNITS_DIAGNOSTIC_POP
|
||||||
return lhs.ascii() <=> rhs.ascii();
|
return lhs.ascii() <=> rhs.ascii();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user