llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> We have type information for them now, so we can do this. --- Full diff: https://github.com/llvm/llvm-project/pull/106366.diff 2 Files Affected: - (modified) clang/lib/AST/ByteCode/Interp.h (+1-1) - (modified) clang/test/AST/ByteCode/arrays.cpp (+9) ``````````diff diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h index 7ba51f737db491..72f4e8e2764c4e 100644 --- a/clang/lib/AST/ByteCode/Interp.h +++ b/clang/lib/AST/ByteCode/Interp.h @@ -2535,7 +2535,7 @@ inline bool ArrayDecay(InterpState &S, CodePtr OpPC) { if (!CheckRange(S, OpPC, Ptr, CSK_ArrayToPointer)) return false; - if (Ptr.isRoot() || !Ptr.isUnknownSizeArray() || Ptr.isDummy()) { + if (Ptr.isRoot() || !Ptr.isUnknownSizeArray()) { S.Stk.push<Pointer>(Ptr.atIndex(0)); return true; } diff --git a/clang/test/AST/ByteCode/arrays.cpp b/clang/test/AST/ByteCode/arrays.cpp index 47706bedcf3f0c..4097c65f7c6fba 100644 --- a/clang/test/AST/ByteCode/arrays.cpp +++ b/clang/test/AST/ByteCode/arrays.cpp @@ -436,6 +436,15 @@ namespace Incomplete { constexpr int C = *F.a; // both-error {{must be initialized by a constant expression}} \ // both-note {{array-to-pointer decay of array member without known bound}} + struct X { + int a; + int b[]; + }; + extern X x; + constexpr int *xb = x.b; // both-error {{must be initialized by a constant expression}} \ + // both-note {{array-to-pointer decay of array member without known bound}} + + /// These are from test/SemaCXX/constant-expression-cxx11.cpp extern int arr[]; constexpr int *c = &arr[1]; // both-error {{must be initialized by a constant expression}} \ `````````` </details> https://github.com/llvm/llvm-project/pull/106366 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits