public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-4740] analyzer: fix ICE comparing COMPLEX_CSTs [PR97668]
@ 2020-11-05 14:55 David Malcolm
  0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2020-11-05 14:55 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:54cbdb528df16686290ad26e2130a1896915639d

commit r11-4740-g54cbdb528df16686290ad26e2130a1896915639d
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Thu Nov 5 09:54:58 2020 -0500

    analyzer: fix ICE comparing COMPLEX_CSTs [PR97668]
    
    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.

Diff:
---
 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(+)

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-11-05 14:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-05 14:55 [gcc r11-4740] analyzer: fix ICE comparing COMPLEX_CSTs [PR97668] David Malcolm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).