[PATCH] D131155: [clang] Expand array expressions if the filler expression's filler is element dependent

Timm Bäder via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 4 04:47:04 PDT 2022


tbaeder updated this revision to Diff 449932.

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131155/new/

https://reviews.llvm.org/D131155

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/constexpr-array-init.cpp


Index: clang/test/SemaCXX/constexpr-array-init.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/constexpr-array-init.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+
+/// expected-no-diagnostics
+struct Foo {
+  int a;
+  constexpr Foo()
+      : a(get_int()) {
+  }
+
+  constexpr int get_int() const {
+    return 5;
+  }
+};
+
+static constexpr Foo bar[2][1] = {
+    {{}},
+};
+static_assert(bar[0][0].a == 5);
+static_assert(bar[1][0].a == 5);
+
Index: clang/lib/AST/ExprConstant.cpp
===================================================================
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -10695,6 +10695,11 @@
       if (MaybeElementDependentArrayFiller(ILE->getInit(I)))
         return true;
     }
+
+    if (ILE->hasArrayFiller() &&
+        MaybeElementDependentArrayFiller(ILE->getArrayFiller()))
+      return true;
+
     return false;
   }
   return true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131155.449932.patch
Type: text/x-patch
Size: 985 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220804/7a00c4a7/attachment.bin>


More information about the cfe-commits mailing list