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.
[Clang] allow usage of placement new operator in [[msvc::constexpr]] …
…context outside of the std namespace (llvm#119153) Fixes llvm#74924
- Loading branch information
1 parent
10ef00f
commit 1094641
Showing
4 changed files
with
28 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// RUN: %clang_cc1 -fms-compatibility -fms-compatibility-version=19.33 -std=c++20 -ast-dump %s | FileCheck %s | ||
|
||
// CHECK: used operator new | ||
// CHECK: MSConstexprAttr 0x{{[0-9a-f]+}} <col:17, col:23> | ||
[[nodiscard]] [[msvc::constexpr]] inline void* __cdecl operator new(decltype(sizeof(void*)), void* p) noexcept { return p; } | ||
|
||
// CHECK: used constexpr construct_at | ||
// CHECK: AttributedStmt 0x{{[0-9a-f]+}} <col:46, col:88> | ||
// CHECK-NEXT: MSConstexprAttr 0x{{[0-9a-f]+}} <col:48, col:54> | ||
// CHECK-NEXT: ReturnStmt 0x{{[0-9a-f]+}} <col:66, col:88> | ||
constexpr int* construct_at(int* p, int v) { [[msvc::constexpr]] return ::new (p) int(v); } | ||
constexpr bool check_construct_at() { int x; return *construct_at(&x, 42) == 42; } | ||
static_assert(check_construct_at()); |
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