[Patch, Fortran] PR fortran/37588: GENERIC resolution broken for array arguments

Daniel Kraft d@domob.eu
Tue Sep 23 08:14:00 GMT 2008


Tobias Burnus wrote:
> Daniel Kraft wrote:
>> this fixes PR fortran/37588 by adding a missing call to resolve the
>> actual arglist before comparing it against the formal ones of the
>> specific procedures in finding a matching one for generic type-bound
>> procedures.
>>
>> Currently regression testing on GNU/Linux-x86-32.
>> Ok to commit (for trunk only, of course) if no regressions?
> 
> OK - thanks for the patch.

Hi Tobias,

thanks for the quick review!  Thinking about it, however, I found the 
following test still fails and I guess it should be valid:

MODULE m
   IMPLICIT NONE

   TYPE :: t
   CONTAINS
     PROCEDURE, NOPASS :: double
     GENERIC :: double_it => double
   END TYPE t

CONTAINS

   ELEMENTAL INTEGER FUNCTION double (arr)
     IMPLICIT NONE
     INTEGER, INTENT(IN) :: arr
     double = 2 * arr
   END FUNCTION double

END MODULE m

PROGRAM main
   USE m
   IMPLICIT NONE

   TYPE(t) :: obj
   INTEGER :: arr(42), arr2(42), arr3(42)
   INTEGER :: i

   arr = (/ (i, i = 1, 42) /)
   arr2 = obj%double (arr)
   arr3 = obj%double_it (arr)

   IF (ANY (arr2 /= 2 * arr)) THEN
     CALL abort ()
   END IF

   IF (ANY (arr3 /= 2 * arr)) THEN
     CALL abort ()
   END IF
END PROGRAM main

The problem is that ELEMENTAL procedures are not recognized correctly 
because ranks_must_agree is set to constant true in the call to 
gfc_compare_actual_formal (I thought that passing the elemental-flag 
itself would be enough but it seems those two parameters must be set to 
complementary values; doesn't make sense to me, though).

I've got a half-way working patch for this, too, and think it is best to 
combine both.  The program above is really valid, isn't it?

Cheers,
Daniel

-- 
Done:     Arc-Bar-Cav-Sam-Val-Wiz, Dwa-Elf-Gno-Hum-Orc, Law-Neu-Cha, Fem-Mal
To go:    Hea-Kni-Mon-Pri-Ran-Rog-Tou



More information about the Fortran mailing list