Index: libcxx/include/__atomic/is_always_lock_free.h =================================================================== --- libcxx/include/__atomic/is_always_lock_free.h +++ libcxx/include/__atomic/is_always_lock_free.h @@ -20,7 +20,7 @@ template struct __libcpp_is_always_lock_free { // __atomic_always_lock_free is available in all Standard modes - static const bool __value = __atomic_always_lock_free(sizeof(_Tp), 0); + static const bool __value = __atomic_always_lock_free(sizeof(_Tp), nullptr); }; _LIBCPP_END_NAMESPACE_STD Index: libcxx/include/__compare/ordering.h =================================================================== --- libcxx/include/__compare/ordering.h +++ libcxx/include/__compare/ordering.h @@ -39,9 +39,15 @@ template inline constexpr bool __one_of_v = (is_same_v<_Tp, _Args> || ...); +void __literal_zero_is_expected(); + struct _CmpUnspecifiedParam { - _LIBCPP_HIDE_FROM_ABI constexpr - _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {} + consteval + _CmpUnspecifiedParam(int __literal_zero) noexcept { + if (__literal_zero != 0) { + __literal_zero_is_expected(); + } + } template>> _CmpUnspecifiedParam(_Tp) = delete; Index: libcxx/include/__iterator/iterator_traits.h =================================================================== --- libcxx/include/__iterator/iterator_traits.h +++ libcxx/include/__iterator/iterator_traits.h @@ -133,7 +133,7 @@ __void_t* = nullptr, __void_t* = nullptr); public: - static const bool value = decltype(__test<_Tp>(0,0,0,0,0))::value; + static const bool value = decltype(__test<_Tp>(nullptr,nullptr,nullptr,nullptr,nullptr))::value; }; Index: libcxx/include/__memory/unique_ptr.h =================================================================== --- libcxx/include/__memory/unique_ptr.h +++ libcxx/include/__memory/unique_ptr.h @@ -57,7 +57,7 @@ #endif template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 default_delete( - const default_delete<_Up>&, typename enable_if::value>::type* = 0) _NOEXCEPT {} + const default_delete<_Up>&, typename enable_if::value>::type* = nullptr) _NOEXCEPT {} _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 void operator()(_Tp* __ptr) const _NOEXCEPT { static_assert(sizeof(_Tp) >= 0, "cannot delete an incomplete type"); @@ -82,7 +82,7 @@ template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 - default_delete(const default_delete<_Up[]>&, typename _EnableIfConvertible<_Up>::type* = 0) _NOEXCEPT {} + default_delete(const default_delete<_Up[]>&, typename _EnableIfConvertible<_Up>::type* = nullptr) _NOEXCEPT {} template _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX23 typename _EnableIfConvertible<_Up>::type Index: libcxx/include/__memory/uses_allocator.h =================================================================== --- libcxx/include/__memory/uses_allocator.h +++ libcxx/include/__memory/uses_allocator.h @@ -25,9 +25,9 @@ { private: template static false_type __test(...); - template static true_type __test(typename _Up::allocator_type* = 0); + template static true_type __test(typename _Up::allocator_type* = nullptr); public: - static const bool value = decltype(__test<_Tp>(0))::value; + static const bool value = decltype(__test<_Tp>(nullptr))::value; }; template ::value> Index: libcxx/test/libcxx/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp =================================================================== --- libcxx/test/libcxx/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp +++ libcxx/test/libcxx/language.support/cmp/cmp.categories.pre/zero_type.verify.cpp @@ -8,10 +8,6 @@ // UNSUPPORTED: c++03, c++11, c++14, c++17 -// In MSVC mode, there's a slightly different number of errors printed for -// each of these, so it doesn't add up to the exact expected count of 18. -// XFAIL: msvc - // // Ensure we reject all cases where an argument other than a literal 0 is used @@ -23,9 +19,7 @@ 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(nullptr op v) #define TEST_PASS(v, op) \ void(v op 0); \ @@ -33,13 +27,13 @@ template void test_category(T v) { - TEST_FAIL(v, ==); // expected-error 18 {{}} - TEST_FAIL(v, !=); // expected-error 18 {{}} - TEST_FAIL(v, <); // expected-error 18 {{}} - TEST_FAIL(v, <=); // expected-error 18 {{}} - TEST_FAIL(v, >); // expected-error 18 {{}} - TEST_FAIL(v, >=); // expected-error 18 {{}} - TEST_FAIL(v, <=>); // expected-error 18 {{}} + 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, !=); Index: libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp =================================================================== --- libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp +++ libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/default.pass.cpp @@ -73,18 +73,18 @@ #endif { std::unique_ptr p; - assert(p.get() == 0); + assert(p.get() == nullptr); } { std::unique_ptr > p; - assert(p.get() == 0); + assert(p.get() == nullptr); assert(p.get_deleter().state() == 0); p.get_deleter().set_state(5); assert(p.get_deleter().state() == 5); } { std::unique_ptr > p; - assert(p.get() == 0); + assert(p.get() == nullptr); assert(p.get_deleter().state() == 0); } Index: libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move.pass.cpp =================================================================== --- libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move.pass.cpp +++ libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/move.pass.cpp @@ -90,7 +90,7 @@ A* p = s.get(); APtr s2 = std::move(s); assert(s2.get() == p); - assert(s.get() == 0); + assert(s.get() == nullptr); if (!TEST_IS_CONSTANT_EVALUATED) assert(A::count == expect_alive); } @@ -106,7 +106,7 @@ A* p = s.get(); APtr s2 = std::move(s); assert(s2.get() == p); - assert(s.get() == 0); + assert(s.get() == nullptr); if (!TEST_IS_CONSTANT_EVALUATED) assert(A::count == expect_alive); assert(s2.get_deleter().state() == 5); @@ -123,7 +123,7 @@ A* p = s.get(); APtr s2 = std::move(s); assert(s2.get() == p); - assert(s.get() == 0); + assert(s.get() == nullptr); if (!TEST_IS_CONSTANT_EVALUATED) assert(A::count == expect_alive); d.set_state(6); Index: libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/null.pass.cpp =================================================================== --- libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/null.pass.cpp +++ libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/null.pass.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// // UNSUPPORTED: c++03 +// ADDITIONAL_COMPILE_FLAGS: -Wno-zero-as-null-pointer-constant // Index: libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/nullptr.pass.cpp =================================================================== --- libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/nullptr.pass.cpp +++ libcxx/test/std/utilities/smartptr/unique.ptr/unique.ptr.class/unique.ptr.ctor/nullptr.pass.cpp @@ -40,16 +40,16 @@ #endif { std::unique_ptr p(nullptr); - assert(p.get() == 0); + assert(p.get() == nullptr); } { std::unique_ptr > p(nullptr); - assert(p.get() == 0); + assert(p.get() == nullptr); assert(p.get_deleter().state() == 0); } { std::unique_ptr > p(nullptr); - assert(p.get() == 0); + assert(p.get() == nullptr); assert(p.get_deleter().state() == 0); } } Index: libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.const_first_const_second_cxx03.pass.cpp =================================================================== --- libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.const_first_const_second_cxx03.pass.cpp +++ libcxx/test/std/utilities/utility/pairs/pairs.pair/ctor.const_first_const_second_cxx03.pass.cpp @@ -30,7 +30,7 @@ { { typedef std::pair P; - P p(3.5f, 0); + P p(3.5f, nullptr); assert(p.first == 3.5f); assert(p.second == nullptr); } Index: libcxx/test/support/controlled_allocators.h =================================================================== --- libcxx/test/support/controlled_allocators.h +++ libcxx/test/support/controlled_allocators.h @@ -72,7 +72,7 @@ std::size_t last_size = 0; std::size_t last_align = 0; - void * last_pointer = 0; + void * last_pointer = nullptr; std::size_t last_alloc_size = 0; std::size_t last_alloc_align = 0; Index: libcxx/utils/libcxx/test/dsl.py =================================================================== --- libcxx/utils/libcxx/test/dsl.py +++ libcxx/utils/libcxx/test/dsl.py @@ -253,7 +253,7 @@ #include int main(int argc, char** argv) { for (int i = 1; i < argc; i++) { - if (::setlocale(LC_ALL, argv[i]) != NULL) { + if (::setlocale(LC_ALL, argv[i]) != nullptr) { return 0; } } Index: libcxx/utils/libcxx/test/params.py =================================================================== --- libcxx/utils/libcxx/test/params.py +++ libcxx/utils/libcxx/test/params.py @@ -18,6 +18,7 @@ '-Wshadow', '-Wundef', '-Wunused-template', + '-Wzero-as-null-pointer-constant', '-Wno-unused-command-line-argument', '-Wno-attributes', '-Wno-pessimizing-move', Index: libunwind/test/forceunwind.pass.cpp =================================================================== --- libunwind/test/forceunwind.pass.cpp +++ libunwind/test/forceunwind.pass.cpp @@ -41,7 +41,7 @@ assert(exceptionObject == &ex); assert(stop_parameter == &foo); - Dl_info info = {0, 0, 0, 0}; + Dl_info info = {nullptr, nullptr, nullptr, nullptr}; // Unwind util the main is reached, above frames depend on the platform and // architecture. Index: libunwind/test/signal_unwind.pass.cpp =================================================================== --- libunwind/test/signal_unwind.pass.cpp +++ libunwind/test/signal_unwind.pass.cpp @@ -26,7 +26,7 @@ _Unwind_Reason_Code frame_handler(struct _Unwind_Context* ctx, void* arg) { (void)arg; - Dl_info info = { 0, 0, 0, 0 }; + Dl_info info = { nullptr, nullptr, nullptr, nullptr }; // Unwind util the main is reached, above frames depend on the platform and // architecture. @@ -39,7 +39,7 @@ void signal_handler(int signum) { (void)signum; - _Unwind_Backtrace(frame_handler, NULL); + _Unwind_Backtrace(frame_handler, nullptr); _Exit(-1); } Index: libunwind/test/unwind_leaffunction.pass.cpp =================================================================== --- libunwind/test/unwind_leaffunction.pass.cpp +++ libunwind/test/unwind_leaffunction.pass.cpp @@ -26,7 +26,7 @@ _Unwind_Reason_Code frame_handler(struct _Unwind_Context* ctx, void* arg) { (void)arg; - Dl_info info = { 0, 0, 0, 0 }; + Dl_info info = { nullptr, nullptr, nullptr, nullptr }; // Unwind until the main is reached, above frames deeped on the platform and // architecture. @@ -39,7 +39,7 @@ void signal_handler(int signum) { (void)signum; - _Unwind_Backtrace(frame_handler, NULL); + _Unwind_Backtrace(frame_handler, nullptr); _Exit(-1); }