[libcxx-commits] [libcxx] 0717621 - [libc++] Add tests for the content of <cstddef>

Louis Dionne via libcxx-commits libcxx-commits at lists.llvm.org
Thu Mar 10 12:54:26 PST 2022


Author: Louis Dionne
Date: 2022-03-10T15:54:15-05:00
New Revision: 071762199f19abd11a0a34c776e42c2345b83ddd

URL: https://github.com/llvm/llvm-project/commit/071762199f19abd11a0a34c776e42c2345b83ddd
DIFF: https://github.com/llvm/llvm-project/commit/071762199f19abd11a0a34c776e42c2345b83ddd.diff

LOG: [libc++] Add tests for the content of <cstddef>

As discussed in D114786.

Differential Revision: https://reviews.llvm.org/D121110

Added: 
    libcxx/test/libcxx/language.support/support.types/cstddef.compile.pass.cpp
    libcxx/test/std/language.support/support.types/cstddef.compile.pass.cpp

Modified: 
    

Removed: 
    


################################################################################
diff  --git a/libcxx/test/libcxx/language.support/support.types/cstddef.compile.pass.cpp b/libcxx/test/libcxx/language.support/support.types/cstddef.compile.pass.cpp
new file mode 100644
index 0000000000000..514353a103029
--- /dev/null
+++ b/libcxx/test/libcxx/language.support/support.types/cstddef.compile.pass.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// Make sure libc++'s <cstddef> defines types like ::nullptr_t in the global namespace.
+// This is a conforming extension to be consistent with other implementations, which all
+// appear to provide that behavior too.
+
+#include <cstddef>
+#include "test_macros.h"
+
+using Ptr
diff T = ::ptr
diff _t;
+using SizeT = ::size_t;
+#if TEST_STD_VER >= 11
+using MaxAlignT = ::max_align_t;
+#endif
+
+// Supported in C++03 mode too for backwards compatibility with previous versions of libc++
+using NullptrT = ::nullptr_t;
+
+// Also ensure that we provide std::nullptr_t in C++03 mode, which is an extension too.
+using StdNullptrT = std::nullptr_t;

diff  --git a/libcxx/test/std/language.support/support.types/cstddef.compile.pass.cpp b/libcxx/test/std/language.support/support.types/cstddef.compile.pass.cpp
new file mode 100644
index 0000000000000..f3556eb4781a4
--- /dev/null
+++ b/libcxx/test/std/language.support/support.types/cstddef.compile.pass.cpp
@@ -0,0 +1,46 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// test the contents of <cstddef>
+
+// namespace std {
+//   using ptr
diff _t = see below;
+//   using size_t = see below;
+//   using max_align_t = see below;
+//   using nullptr_t = decltype(nullptr);
+//
+//   enum class byte : unsigned char {};
+//
+//   // [support.types.byteops], byte type operations
+//      [...] other byte-related functionality is tested elsewhere
+// }
+//
+// #define NULL see below
+// #define offsetof(P, D) see below
+
+#include <cstddef>
+#include "test_macros.h"
+
+using Ptr
diff T = std::ptr
diff _t;
+using SizeT = std::size_t;
+#if TEST_STD_VER >= 11
+using MaxAlignT = std::max_align_t;
+using NullptrT = std::nullptr_t;
+#endif
+
+#if TEST_STD_VER >= 17
+using Byte = std::byte;
+#endif
+
+#ifndef NULL
+#   error "NULL should be defined by <cstddef>"
+#endif
+
+#ifndef offsetof
+#   error "offsetof() should be defined by <cstddef>"
+#endif


        


More information about the libcxx-commits mailing list