1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// UNSUPPORTED: c++03, c++11, c++14, c++17
10// TODO: Change to XFAIL once https://github.com/llvm/llvm-project/issues/40340 is fixed
11// UNSUPPORTED: availability-pmr-missing
12
13// check that functions are marked [[nodiscard]]
14
15// [[nodiscard]] std::pmr::memory_resource::allocate(size_t, size_t);
16// [[nodiscard]] std::pmr::polymorphic_allocator<T>::allocate(size_t, size_t);
17
18#include <memory_resource>
19
20void f() {
21 std::pmr::memory_resource* res = nullptr;
22 res->allocate(bytes: 0); // expected-warning {{ignoring return value of function}}
23 res->allocate(bytes: 0, alignment: 1); // expected-warning {{ignoring return value of function}}
24
25 std::pmr::polymorphic_allocator<int> poly;
26 poly.allocate(n: 0); // expected-warning {{ignoring return value of function}}
27}
28

source code of libcxx/test/std/utilities/utility/mem.res/nodiscard.verify.cpp