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] PR29837 - INTERFACE overloading INTENT problem - valid code is rejected


:ADDPATCH fortran:

This number three in the interface patches, although I have to come clean and admit that it was poasted after I started; win one, lose one :-)

The PR is caused by another tiny coding error and is fixed by the addition of a missing line. The patch and ChangeLog entry say it all. The testcase is that of the reporter.

Regtested on Cygwin_NT/amd64 - OK for trunk, 4.2 and 4.1?

Paul

2006-11-16 Paul Thomas <pault@gcc.gnu.org>

PR fortran/29387
* interface.c (compare_actual_formal): Add missing condition that where be present
for actual arguments being definable error.


2006-11-16 Paul Thomas <pault@gcc.gnu.org>

   PR fortran/29387
   * gfortran.dg/generic_8.f90: New test.
Index: gcc/fortran/interface.c
===================================================================
*** gcc/fortran/interface.c	(revision 118704)
--- gcc/fortran/interface.c	(working copy)
*************** compare_actual_formal (gfc_actual_arglis
*** 1379,1386 ****
  	     && (f->sym->attr.intent == INTENT_OUT
  		   || f->sym->attr.intent == INTENT_INOUT))
  	{
! 	  gfc_error ("Actual argument at %L must be definable to "
! 		     "match dummy INTENT = OUT/INOUT", &a->expr->where);
            return 0;
          }
  
--- 1379,1387 ----
  	     && (f->sym->attr.intent == INTENT_OUT
  		   || f->sym->attr.intent == INTENT_INOUT))
  	{
! 	  if (where)
! 	    gfc_error ("Actual argument at %L must be definable to "
! 		       "match dummy INTENT = OUT/INOUT", &a->expr->where);
            return 0;
          }
  
Index: gcc/testsuite/gfortran.dg/generic_8.f90
===================================================================
*** gcc/testsuite/gfortran.dg/generic_8.f90	(revision 0)
--- gcc/testsuite/gfortran.dg/generic_8.f90	(revision 0)
***************
*** 0 ****
--- 1,31 ----
+ ! { dg-do compile }
+ ! Tests the fix for PR29837, in which the following valid code
+ ! would emit an error because of mistaken INTENT; the wrong
+ ! specific interface would be used for the comparison.
+ !
+ ! Contributed by 
+ !
+ MODULE M
+   IMPLICIT NONE
+   INTERFACE A
+     MODULE PROCEDURE A1,A2
+   END INTERFACE
+ CONTAINS
+ 
+   SUBROUTINE A2(X)
+     INTEGER, INTENT(INOUT) :: X
+   END SUBROUTINE A2
+ 
+   SUBROUTINE A1(X,Y)
+     INTEGER, INTENT(IN) :: X
+     INTEGER, INTENT(OUT) :: Y
+     Y=X
+   END SUBROUTINE A1
+ 
+   SUBROUTINE T(X)
+     INTEGER, INTENT(IN) :: X(:)
+     INTEGER Y
+     CALL A(MAXVAL(X),Y)
+   END SUBROUTINE T
+ END MODULE M
+ ! { dg-final { cleanup-modules "M" } }

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