1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 #include <type_traits>
14 // typedef decltype(nullptr) nullptr_t;
22 void test_conversions()
32 assert(!(p != nullptr));
33 assert(!(nullptr != p));
38 void test_comparisons()
44 assert(!(p != nullptr));
45 assert(!(p < nullptr));
46 assert(!(p > nullptr));
50 assert(!(nullptr != p));
51 assert(!(nullptr < p));
52 assert(!(nullptr > p));
55 #if defined(__clang__)
56 #pragma clang diagnostic push
57 #pragma clang diagnostic ignored "-Wnull-conversion"
59 void test_nullptr_conversions() {
60 // GCC does not accept this due to CWG Defect #1423
61 // http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1423
62 #if defined(__clang__)
73 #if defined(__clang__)
74 #pragma clang diagnostic pop
80 static_assert(sizeof(std::nullptr_t) == sizeof(void*),
81 "sizeof(std::nullptr_t) == sizeof(void*)");
84 test_conversions<std::nullptr_t>();
85 test_conversions<void*>();
86 test_conversions<A*>();
87 test_conversions<void(*)()>();
88 test_conversions<void(A::*)()>();
89 test_conversions<int A::*>();
92 test_comparisons<std::nullptr_t>();
93 test_comparisons<void*>();
94 test_comparisons<A*>();
95 test_comparisons<void(*)()>();
97 test_nullptr_conversions();