llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang Author: Timm Baeder (tbaederr) <details> <summary>Changes</summary> I _think_ this makes sense to do here. This way we have a pointer to the first element on the stack. --- Full diff: https://github.com/llvm/llvm-project/pull/72660.diff 2 Files Affected: - (modified) clang/lib/AST/Interp/Interp.h (+4-2) - (modified) clang/test/AST/Interp/arrays.cpp (+3) ``````````diff diff --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h index 026a95d65488da9..adbeab06923e49e 100644 --- a/clang/lib/AST/Interp/Interp.h +++ b/clang/lib/AST/Interp/Interp.h @@ -1822,10 +1822,12 @@ inline bool ArrayElemPtr(InterpState &S, CodePtr OpPC) { /// Just takes a pointer and checks if its' an incomplete /// array type. inline bool ArrayDecay(InterpState &S, CodePtr OpPC) { - const Pointer &Ptr = S.Stk.peek<Pointer>(); + const Pointer &Ptr = S.Stk.pop<Pointer>(); - if (!Ptr.isUnknownSizeArray()) + if (!Ptr.isUnknownSizeArray()) { + S.Stk.push<Pointer>(Ptr.atIndex(0)); return true; + } const SourceInfo &E = S.Current->getSource(OpPC); S.FFDiag(E, diag::note_constexpr_unsupported_unsized_array); diff --git a/clang/test/AST/Interp/arrays.cpp b/clang/test/AST/Interp/arrays.cpp index 34e0086fb9ee8ca..3babfed5e2b28a5 100644 --- a/clang/test/AST/Interp/arrays.cpp +++ b/clang/test/AST/Interp/arrays.cpp @@ -27,6 +27,9 @@ static_assert(foo[2][3] == &m, ""); static_assert(foo[2][4] == nullptr, ""); +const int SomeInt[] = {1}; +int getSomeInt() { return *SomeInt; } + /// A init list for a primitive value. constexpr int f{5}; static_assert(f == 5, ""); `````````` </details> https://github.com/llvm/llvm-project/pull/72660 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits