Skip to content

Conversation

@tbaederr
Copy link
Contributor

We have type information for them now, so we can do this.

We have type information for them now, so we can do this.
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 28, 2024
@llvmbot
Copy link
Member

llvmbot commented Aug 28, 2024

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

Changes

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 --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}} \

@tbaederr tbaederr merged commit f7a74ec into llvm:main Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants