]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add test-case for PR118924
authorMartin Jambor <mjambor@suse.cz>
Tue, 29 Apr 2025 16:24:29 +0000 (18:24 +0200)
committerMartin Jambor <jamborm@gcc.gnu.org>
Wed, 30 Apr 2025 20:41:21 +0000 (22:41 +0200)
Because the testcase for the issue in master is in a commit I do not
plan to backport to GCC 12 but the issue is avoided by my previous one
nevertheless, I am backporting the testcase in this one.

gcc/testsuite/ChangeLog:

2025-04-29  Martin Jambor  <mjambor@suse.cz>

PR tree-optimization/118924
* g++.dg/tree-ssa/pr118924.C: New test.

gcc/testsuite/g++.dg/tree-ssa/pr118924.C [new file with mode: 0644]

diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr118924.C b/gcc/testsuite/g++.dg/tree-ssa/pr118924.C
new file mode 100644 (file)
index 0000000..c95eaca
--- /dev/null
@@ -0,0 +1,29 @@
+/* { dg-do run } */
+/* { dg-options "-std=c++17 -O2" } */
+
+template <int Size> struct Vector {
+  int m_data[Size];
+  Vector(int, int, int) {}
+};
+enum class E { POINTS, LINES, TRIANGLES };
+
+__attribute__((noipa))
+void getName(E type) {
+  static E check = E::POINTS;
+  if (type == check)
+    check = (E)((int)check + 1);
+  else
+    __builtin_abort ();
+}
+
+int main() {
+  int arr[]{0, 1, 2};
+  for (auto dim : arr) {
+    Vector<3> localInvs(1, 1, 1);
+    localInvs.m_data[dim] = 8;
+  }
+  E types[] = {E::POINTS, E::LINES, E::TRIANGLES};
+  for (auto primType : types)
+    getName(primType);
+  return 0;
+}