https://github.com/tbaederr created 
https://github.com/llvm/llvm-project/pull/226027

None

>From 067b89f95a2d9cdb91aaf0aaaa2b0ddc5514f3c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <[email protected]>
Date: Thu, 24 Sep 2026 07:38:13 +0200
Subject: [PATCH] asdf

---
 clang/lib/AST/ByteCode/Interp.h     | 11 ++++++++++-
 clang/test/AST/ByteCode/invalid.cpp | 12 ++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/clang/lib/AST/ByteCode/Interp.h b/clang/lib/AST/ByteCode/Interp.h
index aec352bc08b32..ad291f46f1e5b 100644
--- a/clang/lib/AST/ByteCode/Interp.h
+++ b/clang/lib/AST/ByteCode/Interp.h
@@ -3637,10 +3637,19 @@ inline bool ArrayDecay(InterpState &S, CodePtr OpPC) {
       return true;
     }
 
-    if (!Ptr.getType()->isArrayType()) {
+    const OpaquePointer &OP = Ptr.asOpaquePointer();
+    if (!OP.getFieldType()->isArrayType()) {
       S.Stk.push<Pointer>(Ptr);
       return true;
     }
+
+    if (OP.isUnknownSizeArray() && OP.PathLength != 0) {
+      S.FFDiag(S.Current->getSource(OpPC),
+               diag::note_constexpr_unsupported_unsized_array);
+      S.Stk.push<Pointer>(Ptr);
+      return true;
+    }
+
     return arrayElemPtrOpaque(S, OpPC, Ptr,
                               APSInt(APInt::getZero(1), /*IsUnsigned=*/true),
                               /*AllowReplace=*/false);
diff --git a/clang/test/AST/ByteCode/invalid.cpp 
b/clang/test/AST/ByteCode/invalid.cpp
index 565d65f60514a..52c91f46ac16d 100644
--- a/clang/test/AST/ByteCode/invalid.cpp
+++ b/clang/test/AST/ByteCode/invalid.cpp
@@ -301,3 +301,15 @@ namespace CompositeFieldInit {
 
   constexpr S2 s2{};
 }
+
+namespace UnsizedArrayAndNonEmptyPath {
+  void foo() {
+    struct S {
+      int m[];
+    } s;
+    constexpr auto p = s.m; // both-error {{must be initialized by a constant 
expression}} \
+                            // both-note {{array-to-pointer decay of array 
member without known bound is not supported}}
+  }
+
+  void bar() { foo(); }
+}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to