diff options
| author | Eric Fiselier <eric@efcs.ca> | 2016-10-25 20:45:17 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2016-10-25 20:45:17 +0000 |
| commit | 8f29ea36c36291d66c2630e23e435bd75c3e491c (patch) | |
| tree | 1fa20e9d794853177c71003f49f8b98d25daa25f /libcxx/test/std/language.support | |
| parent | ae541f6a71ebffc96411fc6ce7437ad1cd03181c (diff) | |
| download | bcm5719-llvm-8f29ea36c36291d66c2630e23e435bd75c3e491c.tar.gz bcm5719-llvm-8f29ea36c36291d66c2630e23e435bd75c3e491c.zip | |
Fix nullptr tests
llvm-svn: 285117
Diffstat (limited to 'libcxx/test/std/language.support')
| -rw-r--r-- | libcxx/test/std/language.support/support.types/nullptr_t.pass.cpp | 25 |
1 files changed, 17 insertions, 8 deletions
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 ca5170f649e..2d0ed741059 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 <type_traits> #include <cassert> +#include "test_macros.h" + // typedef decltype(nullptr) nullptr_t; struct A @@ -34,22 +36,20 @@ void test_conversions() } } +template <class T> struct Voider { typedef void type; }; +template <class T, class = void> struct has_less : std::false_type {}; + +template <class T> struct has_less<T, + typename Voider<decltype(std::declval<T>() < nullptr)>::type> : std::true_type {}; + template <class T> 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<int A::*>(); } { +#ifdef _LIBCPP_HAS_NO_NULLPTR + static_assert(!has_less<std::nullptr_t>::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<void*>::value, ""); +#else + // TODO Enable this assertion when all compilers implement core DR 583. + // static_assert(!has_less<std::nullptr_t>::value, ""); +#endif test_comparisons<std::nullptr_t>(); test_comparisons<void*>(); test_comparisons<A*>(); |

