diff options
author | Timm Baeder <tbaeder@redhat.com> | 2025-05-23 13:00:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-23 13:00:57 +0200 |
commit | 319feac43d8d1362307076ade85dc6d5bc4b4007 (patch) | |
tree | bf9ec9c915c92971040dc70a8c3e915ecf872edf /clang/test/AST/ByteCode | |
parent | 0240129218eebcc5b6b5d31f9458c2f827163c9e (diff) | |
download | llvm-319feac43d8d1362307076ade85dc6d5bc4b4007.zip llvm-319feac43d8d1362307076ade85dc6d5bc4b4007.tar.gz llvm-319feac43d8d1362307076ade85dc6d5bc4b4007.tar.bz2 |
[clang][bytecode] Fix AccessKinds in placement new CheckStore() call (#141123)
CheckStore is for assignments, but we're constructing something here, so
pass AK_Construct instead. We already diagnosed the test case, but as an
assignment.
Diffstat (limited to 'clang/test/AST/ByteCode')
-rw-r--r-- | clang/test/AST/ByteCode/placement-new.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/test/AST/ByteCode/placement-new.cpp b/clang/test/AST/ByteCode/placement-new.cpp index 9015690..81f7782 100644 --- a/clang/test/AST/ByteCode/placement-new.cpp +++ b/clang/test/AST/ByteCode/placement-new.cpp @@ -16,8 +16,8 @@ namespace std { new (p) T((Args&&)args...); // both-note {{in call to}} \ // both-note {{placement new would change type of storage from 'int' to 'float'}} \ // both-note {{construction of subobject of member 'x' of union with active member 'a' is not allowed in a constant expression}} \ - // both-note {{construction of temporary is not allowed}} - + // both-note {{construction of temporary is not allowed}} \ + // both-note {{construction of heap allocated object that has been deleted}} } } @@ -398,3 +398,14 @@ namespace Temp { static_assert((std::construct_at<int>(&temporary, 1), true)); // both-error{{not an integral constant expression}} \ // both-note {{in call}} } + +namespace PlacementNewAfterDelete { + constexpr bool construct_after_lifetime() { + int *p = new int; + delete p; + std::construct_at<int>(p); // both-note {{in call}} + return true; + } + static_assert(construct_after_lifetime()); // both-error {{}} \ + // both-note {{in call}} +} |