From 33c5db58e7d7c509c1f05f873f65e6c7664447ea Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Wed, 19 Nov 2014 05:41:29 +0000 Subject: [PATCH] Revert r222296 to fix bad commit message git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@222316 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../support.types/nullptr_t.pass.cpp | 88 +++++++------------ .../nullptr_t_integral_cast.fail.cpp | 17 ---- .../nullptr_t_integral_cast.pass.cpp | 24 ----- 3 files changed, 34 insertions(+), 95 deletions(-) delete mode 100644 test/language.support/support.types/nullptr_t_integral_cast.fail.cpp delete mode 100644 test/language.support/support.types/nullptr_t_integral_cast.pass.cpp diff --git a/test/language.support/support.types/nullptr_t.pass.cpp b/test/language.support/support.types/nullptr_t.pass.cpp index 4d7c8b0b..6c15fefd 100644 --- a/test/language.support/support.types/nullptr_t.pass.cpp +++ b/test/language.support/support.types/nullptr_t.pass.cpp @@ -18,62 +18,42 @@ struct A A(std::nullptr_t) {} }; -template -void test_conversions() -{ - { - T p = 0; - assert(p == nullptr); - } - { - T p = nullptr; - assert(p == nullptr); - assert(nullptr == p); - assert(!(p != nullptr)); - assert(!(nullptr != p)); - } -} - -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)); -} - - int main() { static_assert(sizeof(std::nullptr_t) == sizeof(void*), "sizeof(std::nullptr_t) == sizeof(void*)"); - - { - test_conversions(); - test_conversions(); - test_conversions(); - test_conversions(); - test_conversions(); - test_conversions(); - } - { - test_comparisons(); - test_comparisons(); - test_comparisons(); - test_comparisons(); - } - { - bool b = nullptr; - assert(!b); - } + A* p = 0; + assert(p == nullptr); + void (A::*pmf)() = 0; +#ifdef __clang__ + // GCC 4.2 can't handle this + assert(pmf == nullptr); +#endif + int A::*pmd = 0; + assert(pmd == nullptr); + A a1(nullptr); + A a2(0); + bool b = nullptr; + assert(!b); + assert(nullptr == nullptr); + assert(nullptr <= nullptr); + assert(nullptr >= nullptr); + assert(!(nullptr != nullptr)); + assert(!(nullptr < nullptr)); + assert(!(nullptr > nullptr)); + A* a = nullptr; + assert(a == nullptr); + assert(a <= nullptr); + assert(a >= nullptr); + assert(!(a != nullptr)); + assert(!(a < nullptr)); + assert(!(a > nullptr)); + assert(nullptr == a); + assert(nullptr <= a); + assert(nullptr >= a); + assert(!(nullptr != a)); + assert(!(nullptr < a)); + assert(!(nullptr > a)); + std::ptrdiff_t i = reinterpret_cast(nullptr); + assert(i == 0); } diff --git a/test/language.support/support.types/nullptr_t_integral_cast.fail.cpp b/test/language.support/support.types/nullptr_t_integral_cast.fail.cpp deleted file mode 100644 index 92bd8794..00000000 --- a/test/language.support/support.types/nullptr_t_integral_cast.fail.cpp +++ /dev/null @@ -1,17 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// typedef decltype(nullptr) nullptr_t; - -#include - -int main() -{ - std::ptrdiff_t i = static_cast(nullptr); -} diff --git a/test/language.support/support.types/nullptr_t_integral_cast.pass.cpp b/test/language.support/support.types/nullptr_t_integral_cast.pass.cpp deleted file mode 100644 index 34c7a93e..00000000 --- a/test/language.support/support.types/nullptr_t_integral_cast.pass.cpp +++ /dev/null @@ -1,24 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// NOTE: nullptr_t emulation cannot handle a reinterpret_cast to an -// integral type -// XFAIL: c++98, c++03 - -// typedef decltype(nullptr) nullptr_t; - - -#include -#include - -int main() -{ - std::ptrdiff_t i = reinterpret_cast(nullptr); - assert(i == 0); -}