Reported by Jon Hurst at http://gcc.gnu.org/ml/fortran/2009-02/msg00152.html Said to compile with 4.0.3, rejected with 4.1/4.2/4.3/4.4. Compiles with NAG f95, ifort, g95, sunf95, openf95 and pgf90. At a glance, it looks valid but I have not checked thoroughly. Test case by Jon Hurst: MODULE funcs CONTAINS INTEGER FUNCTION test1(a,b,opfunc) INTEGER :: a,b INTEGER, EXTERNAL :: opfunc test1 = opfunc( a, b ) END FUNCTION test1 INTEGER FUNCTION sumInts(a,b) INTEGER :: a,b sumInts = a + b END FUNCTION sumInts END MODULE funcs PROGRAM test USE funcs INTEGER :: rs INTEGER, PARAMETER :: a = 2, b = 1 rs = recSum( a, b, test1, sumInts ) write(*,*) "Results", rs CONTAINS RECURSIVE INTEGER FUNCTION recSum( a,b,UserFunction,UserOp ) RESULT( res ) IMPLICIT NONE INTEGER :: a,b INTERFACE INTEGER FUNCTION UserFunction(a,b,opfunc) INTEGER :: a,b INTEGER, EXTERNAL :: opfunc END FUNCTION UserFunction END INTERFACE INTEGER, EXTERNAL :: UserOp res = UserFunction( a,b, UserOp ) if( res .lt. 10 ) then res = recSum( a, res, UserFunction, UserOp ) end if END FUNCTION recSum END PROGRAM test
Confirmed A temporary work around is to remove the interface for UserFunction and declare it to be external. From a very quick look, the test for type and kind is failing because the formal argument does not seem to gain the attribute function at the right time. Cheers Paul
Subject: Bug 39295 Author: pault Date: Thu Feb 26 18:43:50 2009 New Revision: 144449 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144449 Log: 2009-02-26 Paul Thomas <pault@gcc.gnu.org> PR fortran/39295 * interface.c (compare_type_rank_if): Return 1 if the symbols are the same and deal with external procedures where one is identified to be a function or subroutine by usage but the other is not. 2009-02-26 Paul Thomas <pault@gcc.gnu.org> PR fortran/39295 * gfortran.dg/interface_25.f90: New test. * gfortran.dg/interface_26.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/interface_25.f90 trunk/gcc/testsuite/gfortran.dg/interface_26.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/interface.c trunk/gcc/testsuite/ChangeLog
Fixed on trunk. I am not going to fix 4.2 but will do 4.3 in a few days. Cheers Paul
Subject: Bug 39295 Author: pault Date: Sat Mar 7 15:58:49 2009 New Revision: 144695 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=144695 Log: 2009-03-07 Paul Thomas <pault@gcc.gnu.org> PR fortran/39295 * interface.c (compare_type_rank_if): Return 1 if the symbols are the same and deal with external procedures where one is identified to be a function or subroutine by usage but the other is not. 2009-03-07 Paul Thomas <pault@gcc.gnu.org> PR fortran/39295 * gfortran.dg/interface_25.f90: New test. * gfortran.dg/interface_26.f90: New test. Added: branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/interface_25.f90 branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/interface_26.f90 Modified: branches/gcc-4_3-branch/gcc/fortran/ChangeLog branches/gcc-4_3-branch/gcc/fortran/interface.c branches/gcc-4_3-branch/gcc/testsuite/ChangeLog
Fixed on trunk and 4.3. Thanks for the report. Paul