diff --git a/libcxx/include/compare b/libcxx/include/compare --- a/libcxx/include/compare +++ b/libcxx/include/compare @@ -152,7 +152,7 @@ _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEVAL _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {} - template>> + template && is_convertible_v<_Tp, nullptr_t>)>> _CmpUnspecifiedParam(_Tp) = delete; }; diff --git a/libcxx/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp b/libcxx/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp --- a/libcxx/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp @@ -17,40 +17,35 @@ #include -#define TEST_OP(v, op) \ +#define TEST_FAIL(v, op) \ void(v op 0L); \ void(0L op v); \ void(v op nullptr); \ void(nullptr op v); \ void(v op(1 - 1)); \ - void((1 - 1) op v); + void((1 - 1) op v) + +#define TEST_PASS(v, op) \ + void(v op 0); \ + void(0 op v) template void test_category(T v) { - TEST_OP(v, ==); // expected-error 18 {{}} - TEST_OP(v, !=); // expected-error 18 {{}} - TEST_OP(v, <); // expected-error 18 {{}} - TEST_OP(v, <=); // expected-error 18 {{}} - TEST_OP(v, >); // expected-error 18 {{}} - TEST_OP(v, >=); // expected-error 18 {{}} - TEST_OP(v, <=>); // expected-error 18 {{}} - - void(v == 0); - void(0 == v); - void(v != 0); - void(0 != v); - void(v < 0); - void(0 < v); - void(v <= 0); - void(0 <= v); - void(v > 0); - void(0 > v); - void(v >= 0); - void(0 >= v); -#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR - void(v <=> 0); - void(0 <=> v); -#endif + TEST_FAIL(v, ==); // expected-error 12 {{}} + TEST_FAIL(v, !=); // expected-error 12 {{}} + TEST_FAIL(v, <); // expected-error 12 {{}} + TEST_FAIL(v, <=); // expected-error 12 {{}} + TEST_FAIL(v, >); // expected-error 12 {{}} + TEST_FAIL(v, >=); // expected-error 12 {{}} + TEST_FAIL(v, <=>); // expected-error 12 {{}} + + TEST_PASS(v, ==); + TEST_PASS(v, !=); + TEST_PASS(v, <); + TEST_PASS(v, >); + TEST_PASS(v, <=); + TEST_PASS(v, >=); + TEST_PASS(v, <=>); } int main(int, char**) { diff --git a/libcxx/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp --- a/libcxx/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.partialord/partialord.pass.cpp @@ -52,6 +52,17 @@ #endif } +constexpr void test_equality() { +#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR + auto& PartialEq = std::partial_ordering::equivalent; + auto& WeakEq = std::weak_ordering::equivalent; + assert(PartialEq == WeakEq); + + auto& StrongEq = std::strong_ordering::equal; + assert(PartialEq == StrongEq); +#endif +} + constexpr bool test_constexpr() { auto& Eq = std::partial_ordering::equivalent; auto& Less = std::partial_ordering::less; @@ -167,6 +178,8 @@ static_assert(std::partial_ordering::unordered == std::partial_ordering::unordered); } + + test_equality(); #endif return true; @@ -175,6 +188,7 @@ int main(int, char**) { test_static_members(); test_signatures(); + test_equality(); static_assert(test_constexpr(), "constexpr test failed"); return 0; diff --git a/libcxx/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp --- a/libcxx/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.strongord/strongord.pass.cpp @@ -52,6 +52,17 @@ #endif } +constexpr void test_equality() { +#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR + auto& StrongEq = std::strong_ordering::equal; + auto& PartialEq = std::partial_ordering::equivalent; + assert(StrongEq == PartialEq); + + auto& WeakEq = std::weak_ordering::equivalent; + assert(StrongEq == WeakEq); +#endif +} + constexpr bool test_conversion() { static_assert(std::is_convertible::value, ""); @@ -175,6 +186,8 @@ static_assert(std::strong_ordering::greater == std::strong_ordering::greater); } + + test_equality(); #endif return true; @@ -183,6 +196,7 @@ int main(int, char**) { test_static_members(); test_signatures(); + test_equality(); static_assert(test_conversion(), "conversion test failed"); static_assert(test_constexpr(), "constexpr test failed"); diff --git a/libcxx/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp b/libcxx/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp --- a/libcxx/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp +++ b/libcxx/test/std/language.support/cmp/cmp.weakord/weakord.pass.cpp @@ -72,6 +72,17 @@ return true; } +constexpr void test_equality() { +#ifndef TEST_HAS_NO_SPACESHIP_OPERATOR + auto& WeakEq = std::weak_ordering::equivalent; + auto& PartialEq = std::partial_ordering::equivalent; + assert(WeakEq == PartialEq); + + auto& StrongEq = std::strong_ordering::equal; + assert(WeakEq == StrongEq); +#endif +} + constexpr bool test_constexpr() { auto& Eq = std::weak_ordering::equivalent; auto& Less = std::weak_ordering::less; @@ -157,6 +168,8 @@ std::weak_ordering::equivalent); static_assert(std::weak_ordering::greater == std::weak_ordering::greater); } + + test_equality(); #endif return true; @@ -165,6 +178,7 @@ int main(int, char**) { test_static_members(); test_signatures(); + test_equality(); static_assert(test_conversion(), "conversion test failed"); static_assert(test_constexpr(), "constexpr test failed");