Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu.
Pushed to master as r11-4740-g54cbdb528df16686290ad26e2130a1896915639d.

gcc/analyzer/ChangeLog:
        PR analyzer/97668
        * svalue.cc (cmp_cst): Handle COMPLEX_CST.

gcc/testsuite/ChangeLog:
        PR analyzer/97668
        * gcc.dg/analyzer/pr97668.c: New test.
        * gfortran.dg/analyzer/pr97668.f: New test.
---
 gcc/analyzer/svalue.cc                       |  4 +++
 gcc/testsuite/gcc.dg/analyzer/pr97668.c      | 27 ++++++++++++++++++++
 gcc/testsuite/gfortran.dg/analyzer/pr97668.f | 26 +++++++++++++++++++
 3 files changed, 57 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/analyzer/pr97668.c
 create mode 100644 gcc/testsuite/gfortran.dg/analyzer/pr97668.f

diff --git a/gcc/analyzer/svalue.cc b/gcc/analyzer/svalue.cc
index 18d9c376f5e..e9304522b8e 100644
--- a/gcc/analyzer/svalue.cc
+++ b/gcc/analyzer/svalue.cc
@@ -291,6 +291,10 @@ cmp_cst (const_tree cst1, const_tree cst2)
       return memcmp (TREE_REAL_CST_PTR (cst1),
                     TREE_REAL_CST_PTR (cst2),
                     sizeof (real_value));
+    case COMPLEX_CST:
+      if (int cmp_real = cmp_cst (TREE_REALPART (cst1), TREE_REALPART (cst2)))
+       return cmp_real;
+      return cmp_cst (TREE_IMAGPART (cst1), TREE_IMAGPART (cst2));
     case VECTOR_CST:
       if (int cmp_log2_npatterns
            = ((int)VECTOR_CST_LOG2_NPATTERNS (cst1)
diff --git a/gcc/testsuite/gcc.dg/analyzer/pr97668.c 
b/gcc/testsuite/gcc.dg/analyzer/pr97668.c
new file mode 100644
index 00000000000..6ec8164e868
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/analyzer/pr97668.c
@@ -0,0 +1,27 @@
+/* { dg-additional-options "-O1" } */
+
+void
+wb (_Complex double jh)
+{
+  _Complex double af = 0.0;
+
+  do
+    {
+      af += jh;
+    }
+  while (af != 0.0);
+}
+
+_Complex double
+o6 (void)
+{
+  _Complex double ba = 0.0;
+
+  for (;;)
+    {
+      wb (ba);
+      ba = 1.0;
+    }
+
+  return ba;
+}
diff --git a/gcc/testsuite/gfortran.dg/analyzer/pr97668.f 
b/gcc/testsuite/gfortran.dg/analyzer/pr97668.f
new file mode 100644
index 00000000000..568c891cdc4
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/analyzer/pr97668.f
@@ -0,0 +1,26 @@
+c { dg-additional-options "-std=legacy" }
+
+      SUBROUTINE PPADD (A, C, BH)
+
+      COMPLEX DD, FP, FPP, R1, R2
+      DIMENSION A(*), C(*), BH(*)
+
+      DO 136 IG=IS,1
+         FP = (0.,0.)
+         FPP = (0.,0.)
+
+         DO 121 J=1,1
+            DD = 1./2
+            FP = DD
+            FPP = DD+1
+ 121     CONTINUE
+
+         R2 = -FP
+         IF (ABS(R1)-ABS(R2)) 129,129,133
+ 129     R1 = R2/FPP
+ 133     IT = IT+1
+
+ 136  CONTINUE
+
+      RETURN
+      END
-- 
2.26.2

Reply via email to