PROCEDURE declarations

Tobias Burnus burnus@net-b.de
Mon Aug 20 10:37:00 GMT 2007


Hi Janus,

Janus Weil wrote:
> Attached you find the latest version of the patch. This one should
> work with most of Tobias B.'s code samples, in particular it should
> handle implicit interfaces, the PUBLIC attribute and procedures in
> modules.
As written a couple of times: Please include tests. For the final patch
you need them anyhow but even for the initial reviews they would be
helpful. They don't need to be attached in form of diffs - you can also
attach them directly - also for the final patch submission.


Some test results (without looking at the actual patch):

function sub()
  integer :: sub
  sub = 5
end function sub

program p
  implicit none
  !external sub
  !integer :: sub
  procedure(INTEGER) :: sub
  print *, sub()
end program p

The "external sub; integer sub" should be identical to
PROCEDURE(INTEGER), however, the latter gives the error:

Error: Function 'sub' at (1) has no IMPLICIT type


module m
  procedure(), PUBLIC,PRIVATE :: a
  real, public, private :: c
end module m

The PROCEDURE is happily accepted while the REAL gives correctly the error:

Error: ACCESS specification at (1) was already specified



The following does not work (unclassifiably statement):
(See 12.3.2.1)

module m
  interface
    subroutine a()
    end subroutine a
  end interface
  procedure(c) :: f
  interface bar   ! must be generic per C1204
    procedure a,d ! C1207: Must have an explicit interface
                  ! Can be either proc pointer, external proc
                  ! dummy procedure or module procedure
  end interface bar
  interface foo
    procedure c
  end interface foo
  interface foo2
    procedure f
  end interface foo2
contains
  subroutine d(x)
    interface
      subroutine x()
      end subroutine x
    end interface
    interface gen
      procedure x
    end interface
  end subroutine d
  function c(x)
    integer :: x
    real :: c
    c = 3.4*x
  end function c
end module m

(TYPE also allows PROCEDURE but I leave it out as it requires the yet
unsupported POINTER attribute - or type-bound procedures.)

Tobias



More information about the Fortran mailing list