| 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 |
// <memory> |
| 10 |
|
| 11 |
// template <class Alloc> |
| 12 |
// struct allocator_traits |
| 13 |
// { |
| 14 |
// static constexpr pointer allocate(allocator_type& a, size_type n); |
| 15 |
// ... |
| 16 |
// }; |
| 17 |
|
| 18 |
// UNSUPPORTED: c++03, c++11, c++14, c++17 |
| 19 |
|
| 20 |
#include <cstddef> |
| 21 |
#include <memory> |
| 22 |
|
| 23 |
template <class T> |
| 24 |
struct A { |
| 25 |
typedef T value_type; |
| 26 |
value_type* allocate(std::size_t n); |
| 27 |
value_type* allocate(std::size_t n, const void* p); |
| 28 |
}; |
| 29 |
|
| 30 |
void f() { |
| 31 |
A<int> a; |
| 32 |
std::allocator_traits<A<int> >::allocate(a, 10); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} |
| 33 |
std::allocator_traits<A<int> >::allocate(a, 10, nullptr); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} |
| 34 |
} |