This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [fortran, patch] PR17711 - wrong operator name in error message


On Saturday 30 June 2007 17:49:23 Daniel Franke wrote:
> gcc/testsuite:
> 2007-06-30  Daniel Franke  <franke.daniel@gmail.com>
>
> 	PR fortran/17711
> 	* gfortran.dg/operator_4.f90: New test.
> 	* gfortran.dg/operator_5.f90: New test.
> 	* gfortran.dg/module_md5_1.f90: Adjusted MD5 sum due to
> 	increased number of operators in module files.

Forgot to attach the testsuite changes.
Here they are.
Index: gfortran.dg/operator_4.f90
===================================================================
--- gfortran.dg/operator_4.f90	(revision 0)
+++ gfortran.dg/operator_4.f90	(revision 0)
@@ -0,0 +1,100 @@
+! PR 17711 : Verify error message text meets operator in source
+! { dg-do compile }
+
+MODULE mod_t
+  type :: t
+    integer :: x
+  end type
+
+  INTERFACE OPERATOR(==)
+    MODULE PROCEDURE t_eq
+  END INTERFACE
+
+  INTERFACE OPERATOR(/=)
+    MODULE PROCEDURE t_ne
+  END INTERFACE
+
+  INTERFACE OPERATOR(>)
+    MODULE PROCEDURE t_gt
+  END INTERFACE
+
+  INTERFACE OPERATOR(>=)
+    MODULE PROCEDURE t_ge
+  END INTERFACE
+
+  INTERFACE OPERATOR(<)
+    MODULE PROCEDURE t_lt
+  END INTERFACE
+
+  INTERFACE OPERATOR(<=)
+    MODULE PROCEDURE t_le
+  END INTERFACE
+
+CONTAINS
+  LOGICAL FUNCTION t_eq(this, other)
+    TYPE(t), INTENT(in) :: this, other
+    t_eq = (this%x == other%x)
+  END FUNCTION
+
+  LOGICAL FUNCTION t_ne(this, other)
+    TYPE(t), INTENT(in) :: this, other
+    t_ne = (this%x /= other%x)
+  END FUNCTION
+
+  LOGICAL FUNCTION t_gt(this, other)
+    TYPE(t), INTENT(in) :: this, other
+    t_gt = (this%x > other%x)
+  END FUNCTION
+
+  LOGICAL FUNCTION t_ge(this, other)
+    TYPE(t), INTENT(in) :: this, other
+    t_ge = (this%x >= other%x)
+  END FUNCTION
+
+  LOGICAL FUNCTION t_lt(this, other)
+    TYPE(t), INTENT(in) :: this, other
+    t_lt = (this%x < other%x)
+  END FUNCTION
+
+  LOGICAL FUNCTION t_le(this, other)
+    TYPE(t), INTENT(in) :: this, other
+    t_le = (this%x <= other%x)
+  END FUNCTION
+END MODULE
+
+PROGRAM pr17711
+  USE mod_t
+
+  LOGICAL :: A
+  INTEGER :: B
+  TYPE(t) :: C
+
+  A = (A == B)   ! { dg-error "comparison operator '=='" }
+  A = (A.EQ.B)   ! { dg-error "comparison operator '.eq.'" }
+  A = (A /= B)   ! { dg-error "comparison operator '/='" }
+  A = (A.NE.B)   ! { dg-error "comparison operator '.ne.'" }
+  A = (A <= B)   ! { dg-error "comparison operator '<='" }
+  A = (A.LE.B)   ! { dg-error "comparison operator '.le.'" }
+  A = (A <  B)   ! { dg-error "comparison operator '<'" }
+  A = (A.LT.B)   ! { dg-error "comparison operator '.lt.'" }
+  A = (A >= B)   ! { dg-error "comparison operator '>='" }
+  A = (A.GE.B)   ! { dg-error "comparison operator '.ge.'" }
+  A = (A >  B)   ! { dg-error "comparison operator '>'" }
+  A = (A.GT.B)   ! { dg-error "comparison operator '.gt.'" }
+
+  ! this should also work with user defined operators
+  A = (A == C)   ! { dg-error "comparison operator '=='" }
+  A = (A.EQ.C)   ! { dg-error "comparison operator '.eq.'" }
+  A = (A /= C)   ! { dg-error "comparison operator '/='" }
+  A = (A.NE.C)   ! { dg-error "comparison operator '.ne.'" }
+  A = (A <= C)   ! { dg-error "comparison operator '<='" }
+  A = (A.LE.C)   ! { dg-error "comparison operator '.le.'" }
+  A = (A <  C)   ! { dg-error "comparison operator '<'" }
+  A = (A.LT.C)   ! { dg-error "comparison operator '.lt.'" }
+  A = (A >= C)   ! { dg-error "comparison operator '>='" }
+  A = (A.GE.C)   ! { dg-error "comparison operator '.ge.'" }
+  A = (A >  C)   ! { dg-error "comparison operator '>'" }
+  A = (A.GT.C)   ! { dg-error "comparison operator '.gt.'" }
+END PROGRAM
+
+! { dg-final { cleanup-modules "mod_t" } }
Index: gfortran.dg/operator_5.f90
===================================================================
--- gfortran.dg/operator_5.f90	(revision 0)
+++ gfortran.dg/operator_5.f90	(revision 0)
@@ -0,0 +1,51 @@
+! { dg-do compile }
+! { dg-options "-c" }
+
+MODULE mod_t
+  type :: t
+    integer :: x
+  end type
+
+  ! user defined operator
+  INTERFACE OPERATOR(.FOO.)
+    MODULE PROCEDURE t_foo
+  END INTERFACE
+
+  INTERFACE OPERATOR(.FOO.)
+    MODULE PROCEDURE t_foo                  ! { dg-error "already present" }
+  END INTERFACE
+
+  INTERFACE OPERATOR(.FOO.)
+    MODULE PROCEDURE t_bar                  ! { dg-error "Ambiguous interfaces" }
+  END INTERFACE
+
+  ! intrinsic operator
+  INTERFACE OPERATOR(==)
+    MODULE PROCEDURE t_foo
+  END INTERFACE
+
+  INTERFACE OPERATOR(.eq.)
+    MODULE PROCEDURE t_foo                  ! { dg-error "already present" }
+  END INTERFACE
+
+  INTERFACE OPERATOR(==)
+    MODULE PROCEDURE t_bar                  ! { dg-error "Ambiguous interfaces" }
+  END INTERFACE
+
+  INTERFACE OPERATOR(.eq.)
+    MODULE PROCEDURE t_bar                  ! { dg-error "already present" }
+  END INTERFACE
+
+CONTAINS
+  LOGICAL FUNCTION t_foo(this, other)
+    TYPE(t), INTENT(in) :: this, other
+    t_foo = .FALSE.
+  END FUNCTION
+
+  LOGICAL FUNCTION t_bar(this, other)
+    TYPE(t), INTENT(in) :: this, other
+    t_bar = .FALSE.
+  END FUNCTION
+END MODULE
+
+! { dg-final { cleanup-modules "mod_t" } }
Index: gfortran.dg/module_md5_1.f90
===================================================================
--- gfortran.dg/module_md5_1.f90	(revision 126130)
+++ gfortran.dg/module_md5_1.f90	(working copy)
@@ -10,5 +10,5 @@
   use foo
   print *, pi
 end program test
-! { dg-final { scan-module "foo" "MD5:18a257e13c90e3872b7b9400c2fc6e4b" } }
+! { dg-final { scan-module "foo" "MD5:e9de760e2d717ae28a7f05524a41bcdf" } }
 ! { dg-final { cleanup-modules "foo" } }

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]