forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[libc++][memory] Implements LWG3307. (llvm#99776)
As a drive-by added a nodiscard test for allocate_at_least. Implements - LWG33307 std::allocator<void>().allocate(n)
- Loading branch information
Showing
4 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
...est/std/utilities/memory/default.allocator/allocator.members/allocate_at_least.verify.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// 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, c++20 | ||
|
||
// <memory> | ||
|
||
// allocator: | ||
// T* allocate_at_least(size_t n); | ||
|
||
#include <memory> | ||
|
||
struct incomplete; | ||
|
||
void f() { | ||
{ | ||
std::allocator<int> a; | ||
a.allocate_at_least(3); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}} | ||
} | ||
{ | ||
std::allocator<void> a; | ||
[[maybe_unused]] auto b = | ||
a.allocate_at_least(3); // expected-error@*:* {{invalid application of 'sizeof' to an incomplete type 'void'}} | ||
} | ||
{ | ||
std::allocator<incomplete> a; | ||
[[maybe_unused]] auto b = a.allocate_at_least( | ||
3); // expected-error@*:* {{invalid application of 'sizeof' to an incomplete type 'incomplete'}} | ||
} | ||
} |