aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gcc/fortran/arith.cc5
-rw-r--r--gcc/testsuite/gfortran.dg/findloc_9.f9019
2 files changed, 24 insertions, 0 deletions
diff --git a/gcc/fortran/arith.cc b/gcc/fortran/arith.cc
index 86d56406..f9c6658 100644
--- a/gcc/fortran/arith.cc
+++ b/gcc/fortran/arith.cc
@@ -1120,6 +1120,11 @@ gfc_compare_expr (gfc_expr *op1, gfc_expr *op2, gfc_intrinsic_op op)
|| (op1->value.logical && !op2->value.logical));
break;
+ case BT_COMPLEX:
+ gcc_assert (op == INTRINSIC_EQ);
+ rc = mpc_cmp (op1->value.complex, op2->value.complex);
+ break;
+
default:
gfc_internal_error ("gfc_compare_expr(): Bad basic type");
}
diff --git a/gcc/testsuite/gfortran.dg/findloc_9.f90 b/gcc/testsuite/gfortran.dg/findloc_9.f90
new file mode 100644
index 0000000..0597447
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/findloc_9.f90
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! { dg-options "-fdump-tree-original" }
+! PR fortran/110585 - simplification of FINDLOC for constant complex arguments
+
+program mvce
+ implicit none
+ integer, parameter :: a(*) = findloc([(1.,0.),(2.,1.)], (2.,0.))
+ integer, parameter :: b(*) = findloc([(1.,0.),(2.,1.)], (2.,0.), back=.true.)
+ integer, parameter :: c(*) = findloc([(1.,0.),(2.,1.)], (2.,1.))
+ integer, parameter :: d(*) = findloc([(1.,0.),(2.,1.)], (2.,1.), back=.true.)
+ integer, parameter :: e = findloc([(1.,0.),(2.,1.)], (2.,1.), dim=1)
+ if (a(1) /= 0) stop 1
+ if (b(1) /= 0) stop 2
+ if (c(1) /= 2) stop 3
+ if (d(1) /= 2) stop 4
+ if (e /= 2) stop 5
+end
+
+! { dg-final { scan-tree-dump-not "_gfortran_stop_numeric" "original" } }