diff --git a/libcxx/docs/Status/Cxx20.rst b/libcxx/docs/Status/Cxx20.rst --- a/libcxx/docs/Status/Cxx20.rst +++ b/libcxx/docs/Status/Cxx20.rst @@ -40,7 +40,7 @@ .. note:: - .. [#note-P0600] P0600: The missing bits in P0600 are in |sect|\ [mem.res.class] and |sect|\ [mem.poly.allocator.class]. + .. [#note-P0600] P0600: The missing bit in P0600 is |sect|\ [mem.poly.allocator.class]. .. [#note-P0645] P0645: The paper is implemented but still marked as an incomplete feature (the feature-test macro is not set and the libary is only available when built with ``-fexperimental-library``). Not yet implemented LWG-issues will cause API and ABI breakage. diff --git a/libcxx/include/experimental/memory_resource b/libcxx/include/experimental/memory_resource --- a/libcxx/include/experimental/memory_resource +++ b/libcxx/include/experimental/memory_resource @@ -103,7 +103,7 @@ public: virtual ~memory_resource() = default; - _LIBCPP_INLINE_VISIBILITY + _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY void* allocate(size_t __bytes, size_t __align = __max_align) { return do_allocate(__bytes, __align); } diff --git a/libcxx/test/libcxx/experimental/memory/memory.resource.class/allocate.cxx2a.verify.cpp b/libcxx/test/libcxx/experimental/memory/memory.resource.class/allocate.cxx2a.verify.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/libcxx/experimental/memory/memory.resource.class/allocate.cxx2a.verify.cpp @@ -0,0 +1,25 @@ +//===----------------------------------------------------------------------===// +// +// 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 +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// + +// memory_resource: +// void* allocate(size_t __bytes, size_t __align = __max_align) + +#include + +#include "test_memory_resource.h" + +int main(int, char**) { + NullResource R; + R.allocate(3); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} + + return 0; +}