llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Timm Baeder (tbaederr)

<details>
<summary>Changes</summary>

See the attached test case.

---
Full diff: https://github.com/llvm/llvm-project/pull/132775.diff


2 Files Affected:

- (modified) clang/lib/AST/ByteCode/InterpBuiltin.cpp (+12) 
- (modified) clang/test/AST/ByteCode/c.c (+10) 


``````````diff
diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp 
b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
index 5ea1d36a148ae..b305860d34f07 100644
--- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp
+++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp
@@ -2793,6 +2793,18 @@ static bool copyComposite(InterpState &S, CodePtr OpPC, 
const Pointer &Src,
     return true;
   }
 
+  if (DestDesc->isCompositeArray()) {
+    assert(SrcDesc->isCompositeArray());
+    assert(SrcDesc->getNumElems() == DestDesc->getNumElems());
+    for (unsigned I = 0, N = DestDesc->getNumElems(); I != N; ++I) {
+      const Pointer &SrcElem = Src.atIndex(I).narrow();
+      Pointer DestElem = Dest.atIndex(I).narrow();
+      if (!copyComposite(S, OpPC, SrcElem, DestElem, Activate))
+        return false;
+    }
+    return true;
+  }
+
   if (DestDesc->isRecord())
     return copyRecord(S, OpPC, Src, Dest, Activate);
   return Invalid(S, OpPC);
diff --git a/clang/test/AST/ByteCode/c.c b/clang/test/AST/ByteCode/c.c
index 7cb7f96049f2d..fe47f9cab1c9f 100644
--- a/clang/test/AST/ByteCode/c.c
+++ b/clang/test/AST/ByteCode/c.c
@@ -203,6 +203,16 @@ const struct StrA sc = *sb;
 _Static_assert(sc.a == 12, ""); // pedantic-ref-warning {{GNU extension}} \
                                 // pedantic-expected-warning {{GNU extension}}
 
+struct ComplexS {
+  int a;
+  float b;
+  struct StrA sa[2];
+};
+const struct ComplexS CS = {12, 23.0f, {{1}, {2}}};
+const struct ComplexS CS2 = CS;
+_Static_assert(CS2.sa[0].a == 1, ""); // pedantic-ref-warning {{GNU 
extension}} \
+                                      // pedantic-expected-warning {{GNU 
extension}}
+
 _Static_assert(((void*)0 + 1) != (void*)0, ""); // pedantic-expected-warning 
{{arithmetic on a pointer to void is a GNU extension}} \
                                                 // pedantic-expected-warning 
{{not an integer constant expression}} \
                                                 // pedantic-expected-note 
{{cannot perform pointer arithmetic on null pointer}} \

``````````

</details>


https://github.com/llvm/llvm-project/pull/132775
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to