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

Louis Dionne via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 7 05:44:01 PST 2022


ldionne created this revision.
Herald added a project: All.
ldionne requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

As discussed in D114786 <https://reviews.llvm.org/D114786>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D121110

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


Index: libcxx/test/std/language.support/support.types/cstddef.compile.pass.cpp
===================================================================
--- /dev/null
+++ 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 ptrdiff_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 PtrdiffT = std::ptrdiff_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 "offsetoff() should be defined by <cstddef>"
+#endif
Index: libcxx/test/libcxx/language.support/support.types/cstddef.compile.pass.cpp
===================================================================
--- /dev/null
+++ libcxx/test/libcxx/language.support/support.types/cstddef.compile.pass.cpp
@@ -0,0 +1,18 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 ::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.
+//
+// Note that we also support it in C++03 mode, even though nullptr_t is technically
+// new in C++11.
+
+#include <cstddef>
+
+using NullptrT = std::nullptr_t;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D121110.413439.patch
Type: text/x-patch
Size: 2530 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220307/396a9fe2/attachment-0001.bin>


More information about the libcxx-commits mailing list