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// check that functions are marked [[nodiscard]]
10
11// UNSUPPORTED: c++03, c++11, c++14, c++17
12
13// test_memory_resource requires RTTI for dynamic_cast
14// UNSUPPORTED: no-rtti
15
16// <memory_resource>
17
18// polymorphic_allocator::allocate_bytes()
19// polymorphic_allocator::allocate_object()
20// polymorphic_allocator::new_object()
21
22#include <memory_resource>
23
24void func() {
25 std::pmr::polymorphic_allocator<> allocator;
26 allocator.allocate_bytes(1); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
27 allocator.allocate_object<int>(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
28 allocator.new_object<int>(); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
29}
30

source code of libcxx/test/std/utilities/utility/mem.res/mem.poly.allocator.class/mem.poly.allocator.mem/allocate_deallocate_vocabulary.nodiscard.verify.cpp