Skip to content

Commit 2925333

Browse files
committed
[libc++abi] Use std::nullptr_t instead of declaring it manually
Sometimes libc++'s stddef.h wrapper gets included, which defines ::nullptr_t. This test is compiled with -Wshadow -Werror, so shadowing ::nullptr_t with a nullptr_t in main is an error. Include cstddef, which is guaranteed to define std::nullptr_t in C++11 and forward. Reviewed By: ldionne, #libc_abi Differential Revision: https://reviews.llvm.org/D137127
1 parent ada6aa3 commit 2925333

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

libcxxabi/test/catch_reference_nullptr.pass.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
//
77
//===----------------------------------------------------------------------===//
88

9-
// UNSUPPORTED: c++03,
9+
// UNSUPPORTED: c++03
1010
// UNSUPPORTED: no-exceptions
1111

1212
#include <cassert>
13+
#include <cstddef>
1314
#include <cstdlib>
15+
#include <type_traits>
1416

1517
struct A {};
1618

@@ -27,13 +29,13 @@ static void catch_nullptr_test() {
2729

2830
int main(int, char**)
2931
{
30-
using nullptr_t = decltype(nullptr);
32+
static_assert(std::is_same<std::nullptr_t, decltype(nullptr)>::value, "");
3133

3234
// A reference to nullptr_t can catch nullptr.
33-
catch_nullptr_test<nullptr_t, true>();
34-
catch_nullptr_test<const nullptr_t, true>();
35-
catch_nullptr_test<volatile nullptr_t, true>();
36-
catch_nullptr_test<const volatile nullptr_t, true>();
35+
catch_nullptr_test<std::nullptr_t, true>();
36+
catch_nullptr_test<const std::nullptr_t, true>();
37+
catch_nullptr_test<volatile std::nullptr_t, true>();
38+
catch_nullptr_test<const volatile std::nullptr_t, true>();
3739

3840
// No other reference type can.
3941
#if 0

0 commit comments

Comments
 (0)