llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> getType() returns just int for those instead of an array type, so the previous condition resulted in the array index missing int the APValue's LValuePath. --- Full diff: https://github.com/llvm/llvm-project/pull/175176.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Pointer.cpp (+2-2) - (modified) clang/test/AST/ByteCode/new-delete.cpp (+3) ``````````diff diff --git a/clang/lib/AST/ByteCode/Pointer.cpp b/clang/lib/AST/ByteCode/Pointer.cpp index 5d11321d09079..c5e0fd83021d7 100644 --- a/clang/lib/AST/ByteCode/Pointer.cpp +++ b/clang/lib/AST/ByteCode/Pointer.cpp @@ -248,7 +248,7 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { unsigned Index = Ptr.getIndex(); QualType ElemType = Desc->getElemQualType(); Offset += (Index * ASTCtx.getTypeSizeInChars(ElemType)); - if (Ptr.getArray().getType()->isArrayType()) + if (Ptr.getArray().getFieldDesc()->IsArray) Path.push_back(APValue::LValuePathEntry::ArrayIndex(Index)); Ptr = Ptr.getArray(); } else { @@ -278,7 +278,7 @@ APValue Pointer::toAPValue(const ASTContext &ASTCtx) const { } else { Offset += (Index * ASTCtx.getTypeSizeInChars(ElemType)); } - if (Ptr.getArray().getType()->isArrayType()) + if (Ptr.getArray().getFieldDesc()->IsArray) Path.push_back(APValue::LValuePathEntry::ArrayIndex(Index)); Ptr = Ptr.getArray(); } else { diff --git a/clang/test/AST/ByteCode/new-delete.cpp b/clang/test/AST/ByteCode/new-delete.cpp index 9345946a31e99..625f82c973372 100644 --- a/clang/test/AST/ByteCode/new-delete.cpp +++ b/clang/test/AST/ByteCode/new-delete.cpp @@ -14,6 +14,9 @@ constexpr int *Global = new int(12); // both-error {{must be initialized by a co static_assert(*(new int(12)) == 12); // both-error {{not an integral constant expression}} \ // both-note {{allocation performed here was not deallocated}} +static_assert((delete[] (new int[3] + 1), true)); // both-error {{not an integral constant expression}} \ + // both-note {{delete of pointer to subobject '&{*new int[3]#0}[1]'}} + constexpr int a() { new int(12); // both-note {{allocation performed here was not deallocated}} `````````` </details> https://github.com/llvm/llvm-project/pull/175176 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
