This revision was automatically updated to reflect the committed changes.
Closed by commit rGd1942855c431: [clang] Consider array filler in 
MaybeElementDependentArrayfiller() (authored by tbaeder).

Changed prior to commit:
  https://reviews.llvm.org/D131155?vs=449932&id=450230#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131155

Files:
  clang/docs/ReleaseNotes.rst
  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,24 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+/// This test case used to crash in constant evaluation
+/// because of the two-dimensional array with an array
+/// filler expression.
+
+/// 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;
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -62,6 +62,10 @@
   already properly diagnosing this case).
 - Fix clang not properly diagnosing the failing subexpression when chained
   binary operators are used in a ``static_assert`` expression.
+- Fix a crash when evaluating a multi-dimensional array's array filler
+  expression is element-dependent. This fixes
+  `Issue 50601 <https://github.com/llvm/llvm-project/issues/56016>`_.
+
 
 Improvements to Clang's diagnostics
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


Index: clang/test/SemaCXX/constexpr-array-init.cpp
===================================================================
--- /dev/null
+++ clang/test/SemaCXX/constexpr-array-init.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+/// This test case used to crash in constant evaluation
+/// because of the two-dimensional array with an array
+/// filler expression.
+
+/// 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;
Index: clang/docs/ReleaseNotes.rst
===================================================================
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -62,6 +62,10 @@
   already properly diagnosing this case).
 - Fix clang not properly diagnosing the failing subexpression when chained
   binary operators are used in a ``static_assert`` expression.
+- Fix a crash when evaluating a multi-dimensional array's array filler
+  expression is element-dependent. This fixes
+  `Issue 50601 <https://github.com/llvm/llvm-project/issues/56016>`_.
+
 
 Improvements to Clang's diagnostics
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to