aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorHarald Anlauf <anlauf@gmx.de>2023-07-07 20:25:06 +0200
committerHarald Anlauf <anlauf@gmx.de>2023-07-08 15:57:33 +0200
commit7ac1581d066a6f3a0d4acf1042a74634258b4966 (patch)
tree64a1ddaad8045bda3d3989b13b4dc7599a3e154e /gcc
parent38b7125be9ce76402cf6ea16cdbc6055358a6e54 (diff)
downloadgcc-7ac1581d066a6f3a0d4acf1042a74634258b4966.zip
gcc-7ac1581d066a6f3a0d4acf1042a74634258b4966.tar.gz
gcc-7ac1581d066a6f3a0d4acf1042a74634258b4966.tar.bz2
Fortran: simplification of FINDLOC for constant complex arguments [PR110585]
gcc/fortran/ChangeLog: PR fortran/110585 * arith.cc (gfc_compare_expr): Handle equality comparison of constant complex gfc_expr arguments. gcc/testsuite/ChangeLog: PR fortran/110585 * gfortran.dg/findloc_9.f90: New test.
Diffstat (limited to 'gcc')
-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" } }