diff options
-rw-r--r-- | clang/lib/AST/ByteCode/Interp.cpp | 2 | ||||
-rw-r--r-- | clang/test/AST/ByteCode/placement-new.cpp | 9 |
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/AST/ByteCode/Interp.cpp b/clang/lib/AST/ByteCode/Interp.cpp index 7cc0d2a..1766057 100644 --- a/clang/lib/AST/ByteCode/Interp.cpp +++ b/clang/lib/AST/ByteCode/Interp.cpp @@ -1703,6 +1703,8 @@ bool CheckNewTypeMismatch(InterpState &S, CodePtr OpPC, const Expr *E, std::optional<uint64_t> ArraySize) { const Pointer &Ptr = S.Stk.peek<Pointer>(); + if (!CheckTemporary(S, OpPC, Ptr, AK_Construct)) + return false; if (!CheckStore(S, OpPC, Ptr)) return false; diff --git a/clang/test/AST/ByteCode/placement-new.cpp b/clang/test/AST/ByteCode/placement-new.cpp index 14b893c..9015690 100644 --- a/clang/test/AST/ByteCode/placement-new.cpp +++ b/clang/test/AST/ByteCode/placement-new.cpp @@ -15,7 +15,8 @@ namespace std { constexpr void construct_at(void *p, Args &&...args) { 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 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}} } } @@ -391,3 +392,9 @@ namespace MemMove { static_assert(foo() == 123); } + +namespace Temp { + constexpr int &&temporary = 0; // both-note {{created here}} + static_assert((std::construct_at<int>(&temporary, 1), true)); // both-error{{not an integral constant expression}} \ + // both-note {{in call}} +} |