From 8f29ea36c36291d66c2630e23e435bd75c3e491c Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Tue, 25 Oct 2016 20:45:17 +0000 Subject: [PATCH] Fix nullptr tests llvm-svn: 285117 --- libcxx/include/__nullptr | 4 --- .../support.types/nullptr_t.pass.cpp | 25 +++++++++++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/libcxx/include/__nullptr b/libcxx/include/__nullptr index 95415a6325a3..38ee379eff9d 100644 --- a/libcxx/include/__nullptr +++ b/libcxx/include/__nullptr @@ -42,10 +42,6 @@ struct _LIBCPP_TYPE_VIS_ONLY nullptr_t friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator==(nullptr_t, nullptr_t) {return true;} friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator!=(nullptr_t, nullptr_t) {return false;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<(nullptr_t, nullptr_t) {return false;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator<=(nullptr_t, nullptr_t) {return true;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>(nullptr_t, nullptr_t) {return false;} - friend _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR bool operator>=(nullptr_t, nullptr_t) {return true;} }; inline _LIBCPP_ALWAYS_INLINE _LIBCPP_CONSTEXPR nullptr_t __get_nullptr_t() {return nullptr_t(0);} diff --git a/libcxx/test/std/language.support/support.types/nullptr_t.pass.cpp b/libcxx/test/std/language.support/support.types/nullptr_t.pass.cpp index ca5170f649ed..2d0ed7410590 100644 --- a/libcxx/test/std/language.support/support.types/nullptr_t.pass.cpp +++ b/libcxx/test/std/language.support/support.types/nullptr_t.pass.cpp @@ -11,6 +11,8 @@ #include #include +#include "test_macros.h" + // typedef decltype(nullptr) nullptr_t; struct A @@ -34,22 +36,20 @@ void test_conversions() } } +template struct Voider { typedef void type; }; +template struct has_less : std::false_type {}; + +template struct has_less() < nullptr)>::type> : std::true_type {}; + template void test_comparisons() { T p = nullptr; assert(p == nullptr); - assert(p <= nullptr); - assert(p >= nullptr); assert(!(p != nullptr)); - assert(!(p < nullptr)); - assert(!(p > nullptr)); assert(nullptr == p); - assert(nullptr <= p); - assert(nullptr >= p); assert(!(nullptr != p)); - assert(!(nullptr < p)); - assert(!(nullptr > p)); } #if defined(__clang__) @@ -89,6 +89,15 @@ int main() test_conversions(); } { +#ifdef _LIBCPP_HAS_NO_NULLPTR + static_assert(!has_less::value, ""); + // FIXME: our c++03 nullptr emulation still allows for comparisons + // with other pointer types by way of the conversion operator. + //static_assert(!has_less::value, ""); +#else + // TODO Enable this assertion when all compilers implement core DR 583. + // static_assert(!has_less::value, ""); +#endif test_comparisons(); test_comparisons(); test_comparisons();