]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgfortran: Fix PR95647 by changing the interfaces of operators .eq. and .ne.
authorSteve Kargl <sgk@troutmask.apl.washington.edu>
Fri, 12 Feb 2021 21:04:14 +0000 (13:04 -0800)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Fri, 12 Feb 2021 21:04:14 +0000 (13:04 -0800)
The FE converts the old school .eq. to ==,
and then tracks the ==.  The module starts with == and so it does not
properly overload the .eq.  Reversing the interfaces fixes this.

2021-02-12  Steve Kargl <sgk@troutmask.apl.washington.edu>

libgfortran/ChangeLog:

PR libfortran/95647
* ieee/ieee_arithmetic.F90: Flip interfaces of operators .eq. to
== and .ne. to /= .

gcc/testsuite/ChangeLog:

PR libfortran/95647
* gfortran.dg/ieee/ieee_12.f90: New test.

gcc/testsuite/gfortran.dg/ieee/ieee_12.f90 [new file with mode: 0644]
libgfortran/ieee/ieee_arithmetic.F90

diff --git a/gcc/testsuite/gfortran.dg/ieee/ieee_12.f90 b/gcc/testsuite/gfortran.dg/ieee/ieee_12.f90
new file mode 100644 (file)
index 0000000..139a701
--- /dev/null
@@ -0,0 +1,24 @@
+! { dg-do run }
+! PR95647 operator(.eq.) and operator(==) treated differently
+program test
+  use, intrinsic :: ieee_arithmetic, only :                 &
+&                ieee_class,                                       &
+&                ieee_class_type,                                  &
+&                ieee_negative_normal,                             &
+&                ieee_positive_normal,                             &
+&                operator(.eq.), operator(.ne.)
+  integer :: good
+  real(4) r4
+  type(ieee_class_type) class1
+  good = 0
+  r4 = 1.0
+  class1 = ieee_class(r4)
+  if (class1 .eq. ieee_positive_normal) good = good + 1
+  if (class1 .ne. ieee_negative_normal) good = good + 1
+  r4 = -1.0
+  class1 = ieee_class(r4)
+  if (class1 .eq. ieee_negative_normal) good = good + 1
+  if (class1 .ne. ieee_positive_normal) good = good + 1
+  if (good /= 4) call abort
+end program test
+
index 2b4d8afd514304ca91d5c43f920138a4839b4054..ff35cf731520c27a6c814dae98b9f0c747e657c3 100644 (file)
@@ -77,15 +77,16 @@ module IEEE_ARITHMETIC
 
 
   ! Equality operators on the derived types
-  interface operator (==)
+  ! Note, the FE overloads .eq. to == and .ne. to /=
+  interface operator (.eq.)
     module procedure IEEE_CLASS_TYPE_EQ, IEEE_ROUND_TYPE_EQ
   end interface
-  public :: operator(==)
+  public :: operator(.eq.)
 
-  interface operator (/=)
+  interface operator (.ne.)
     module procedure IEEE_CLASS_TYPE_NE, IEEE_ROUND_TYPE_NE
   end interface
-  public :: operator (/=)
+  public :: operator (.ne.)
 
 
   ! IEEE_IS_FINITE