A PURE function that is part of an INTERFACE block is not resolved as being a
function. Gfortran gives the following warning for the code attached at the end
of this description:

module_procedure-1.f90: In function 'show':
module_procedure-1.f90:30: warning: unused variable 'test'

I originally tested this using GNU Fortran 95 (GCC 4.1.0 20050602
(experimental)) and retested it using GNU Fortran 95 (GCC 4.1.0 20050608
(experimental)).

---

MODULE procedures
   PUBLIC               :: test

   PRIVATE              :: test1,test2

   INTERFACE test
      MODULE PROCEDURE test1,test2
   END INTERFACE test
CONTAINS
   PURE FUNCTION test1 (x) RESULT(r)
      REAL(KIND(0.0d0)), INTENT(IN) :: x
      REAL(KIND(0.0d0))             :: r

      r=x+1.0d0
   END FUNCTION test1

   PURE FUNCTION test2 (x) RESULT(r)
      REAL(KIND(0.0d0)), DIMENSION(:), INTENT(IN)  :: x
      REAL(KIND(0.0d0)), DIMENSION(SIZE(x))        :: r

      FORALL (i=1:SIZE(x))
         r(i)=x(i)+1.0d0
      END FORALL
   END FUNCTION test2
END MODULE procedures

MODULE actions
   USE procedures
CONTAINS
   SUBROUTINE show (x)
      REAL(KIND(0.0d0)), DIMENSION(:)        :: x
      REAL(KIND(0.0d0)), DIMENSION(SIZE(x))  :: d

      d=test (x)
      WRITE (*,'(F8.6)') d
   END SUBROUTINE show
END MODULE actions

PROGRAM module_procedure_1
   USE actions

   REAL(KIND(0.0d0)), DIMENSION(2)  :: x

   x=(/ 1.0d0,0.0d0 /)

   CALL show (x)

END PROGRAM module_procedure_1

-- 
           Summary: PURE function in INTERFACE block not resolved as being a
                    function
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mhesseli at caltech dot edu
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: powerpc-apple-darwin7.9.0
  GCC host triplet: powerpc-apple-darwin7.9.0
GCC target triplet: powerpc-apple-darwin7.9.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21961

Reply via email to