Reported by John McFarland at
http://gcc.gnu.org/ml/fortran/2010-06/msg00286.html

If one uses
  procedure(<interface>), pointer :: f
at multiple scopes of the same program, gfortran treats the proc-pointer name
("f") as external name - and thus rejects using it once as function and once as
subroutine name:

Error: Global name 'f' at (1) is already being used as a SUBROUTINE at (2)


Test case by John McFarland:

MODULE m
  IMPLICIT NONE
CONTAINS
  FUNCTION func(x) RESULT(y)
    INTEGER :: x,y
    y = x *2
  END FUNCTION func

  SUBROUTINE sub(x)
    INTEGER :: x
    PRINT*, x
  END SUBROUTINE sub

  SUBROUTINE use_func()
    PROCEDURE(func), POINTER :: f
    INTEGER :: y
    f => func
    y = f(2)
  END SUBROUTINE use_func

  SUBROUTINE use_sub()
    PROCEDURE(sub), POINTER :: f
    f => sub
    CALL f(2)
  END SUBROUTINE use_sub
END MODULE m


-- 
           Summary: Procedure-pointer name is wrongly regarded as "external
                    procedure"
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: burnus at gcc dot gnu dot org


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

Reply via email to