summaryrefslogtreecommitdiff
path: root/libcxx/test/std/utilities/utility/mem.res/nodiscard.verify.cpp
blob: 8adfa03ed034b82c42065943b210ad75cd820291 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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

// check that functions are marked [[nodiscard]]

// [[nodiscard]] std::pmr::memory_resource::allocate(size_t, size_t);
// [[nodiscard]] std::pmr::polymorphic_allocator<T>::allocate(size_t, size_t);

#include <memory_resource>

void f() {
  std::pmr::memory_resource* res = nullptr;
  res->allocate(0);    // expected-warning {{ignoring return value of function}}
  res->allocate(0, 1); // expected-warning {{ignoring return value of function}}

  std::pmr::polymorphic_allocator<int> poly;
  poly.allocate(0); // expected-warning {{ignoring return value of function}}
}