https://gcc.gnu.org/g:81b30ef214690b6521753293bf2fcb2339055b54

commit r12-11080-g81b30ef214690b6521753293bf2fcb2339055b54
Author: Martin Jambor <mjam...@suse.cz>
Date:   Tue Apr 29 18:24:29 2025 +0200

    Add test-case for PR118924
    
    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  <mjam...@suse.cz>
    
            PR tree-optimization/118924
            * g++.dg/tree-ssa/pr118924.C: New test.

Diff:
---
 gcc/testsuite/g++.dg/tree-ssa/pr118924.C | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/gcc/testsuite/g++.dg/tree-ssa/pr118924.C 
b/gcc/testsuite/g++.dg/tree-ssa/pr118924.C
new file mode 100644
index 000000000000..c95eacafc9ce
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/pr118924.C
@@ -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;
+}

Reply via email to