llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> This was missing. --- Full diff: https://github.com/llvm/llvm-project/pull/204063.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/EvaluationResult.cpp (+7) - (modified) clang/test/AST/ByteCode/new-delete.cpp (+14-1) ``````````diff diff --git a/clang/lib/AST/ByteCode/EvaluationResult.cpp b/clang/lib/AST/ByteCode/EvaluationResult.cpp index 24f242758324e..10c83942fbde1 100644 --- a/clang/lib/AST/ByteCode/EvaluationResult.cpp +++ b/clang/lib/AST/ByteCode/EvaluationResult.cpp @@ -173,6 +173,13 @@ static void collectBlocks(PtrView Ptr, llvm::SetVector<const Block *> &Blocks) { if (const Record *R = Desc->ElemRecord; R && R->hasPtrField()) { + for (const Record::Base &B : R->bases()) { + if (!B.R->hasPtrField()) + continue; + PtrView BasePtr = Ptr.atField(B.Offset); + collectBlocks(BasePtr, Blocks); + } + for (const Record::Field &F : R->fields()) { if (!isOrHasPtr(F.Desc)) continue; diff --git a/clang/test/AST/ByteCode/new-delete.cpp b/clang/test/AST/ByteCode/new-delete.cpp index 7481eccd2c03a..dd61accc898cd 100644 --- a/clang/test/AST/ByteCode/new-delete.cpp +++ b/clang/test/AST/ByteCode/new-delete.cpp @@ -1226,7 +1226,7 @@ namespace ArrayDestSize { static_assert(dynarray<char>(3, 2) == 'x'); // both-error {{constant expression}} both-note {{in call}} } -namespace OpertorArrayDelete { +namespace OperatorArrayDelete { struct S {}; using State = S[2]; constexpr unsigned run(const State *s) { @@ -1241,6 +1241,19 @@ namespace OpertorArrayDelete { // both-note {{in call to}} } +namespace AllocInBase { + struct A { + int *p; + constexpr A() : p(new int) {} // both-note {{heap allocation performed here}} + }; + struct B : A { + int *m; + constexpr B() : m(new int) {} + }; + constexpr B b{}; // both-error {{must be initialized by a constant expression}} \ + // both-note {{pointer to heap-allocated object is not a constant expression}} +} + #else /// Make sure we reject this prior to C++20 constexpr int a() { // both-error {{never produces a constant expression}} `````````` </details> https://github.com/llvm/llvm-project/pull/204063 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
