This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[Patch, fortran] PR25077 - No diagnostic if interface assignment modifies intrinsic type assigments


:ADDPATCH fortran:

The title, ChangeLog and patch speak for themselves here. The only question that I would have about this patch is whether we want an error or a warning? At present, gfortran silently ignores such interface assignments and uses the intrinsic assignments. The testcase is developed from the reporter's example.

Regested on SUSE10.1/AMD64 - OK for trunk and 4.1?

Paul

2006-08-19 Paul Thomas <pault@gcc.gnu.org>

   PR fortran/25077
   * interface.c (check_operator_interface): Throw error if the
   interface assignment tries to change intrinsic type assigments.

2006-08-19 Paul Thomas <pault@gcc.gnu.org>

   PR fortran/25077
   * gfortran.dg/redefined_intrinsic_assignment.f90: New test.

Index: gcc/fortran/interface.c
===================================================================
*** gcc/fortran/interface.c	(revision 116226)
--- gcc/fortran/interface.c	(working copy)
*************** check_operator_interface (gfc_interface 
*** 531,536 ****
--- 531,548 ----
  	     &intr->where);
  	  return;
  	}
+       if (sym->formal && sym->formal->next
+ 	    && sym->formal->sym->ts.type != BT_DERIVED
+ 	    && sym->formal->next->sym->ts.type != BT_DERIVED
+ 	    && (sym->formal->sym->ts.type == sym->formal->next->sym->ts.type
+ 		  || (gfc_numeric_ts (&sym->formal->sym->ts)
+ 			&& gfc_numeric_ts (&sym->formal->next->sym->ts))))
+ 	{
+ 	  gfc_error
+ 	    ("Assignment operator interface at %L must not redefine "
+ 	     "an INTRINSIC type assignment", &intr->where);
+ 	  return;
+ 	}
      }
    else
      {
Index: gcc/testsuite/gfortran.dg/redefined_intrinsic_assignment.f90
===================================================================
*** gcc/testsuite/gfortran.dg/redefined_intrinsic_assignment.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/redefined_intrinsic_assignment.f90	(revision 0)
***************
*** 0 ****
--- 1,19 ----
+ ! { dg-do compile }
+ ! Tests the fix for PR25077 in which no diagnostic was produced
+ ! for the redefinition of an intrinsic type assignment.
+ !
+ ! Contributed by Joost VandeVondele  <jv244@cam.ac.uk>
+ !
+ MODULE M1
+  IMPLICIT NONE
+  INTERFACE ASSIGNMENT(=)
+   MODULE PROCEDURE T1 ! { dg-error "must not redefine an INTRINSIC" }
+  END INTERFACE
+ CONTAINS
+  SUBROUTINE T1(I,J)
+    INTEGER, INTENT(OUT)  :: I
+    INTEGER, INTENT(IN)  :: J
+    I=-J
+  END SUBROUTINE T1
+ END MODULE M1
+ 

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