PROCEDURE declarations

Tobias Burnus burnus@net-b.de
Fri Aug 24 02:45:00 GMT 2007


Janus Weil wrote:
> I also implemented some new checks (e.g. for C1204, C1217 and C1218)
> in my patch, which you find attached. It should be able to cover a
> broad spectrum of procedure declarations by now and also includes my
> recent bugfixes for abstract interfaces.

Some more bugs. The following is invalid as one imports a symbol twice;
nonetheless gfortran accepts it:

interface
  subroutine foo()
  end subroutine foo
end interface
! NAG f95:  ERROR: Duplicate subprogram name FOO
procedure(foo) :: foo
end

And the following is a module with a generic specification
("operator(...)" or "assignment(=)"), but gfortran rejects it:

module X
interface
  function foo(a)
    integer,intent(in) :: a
    integer :: foo
  end function foo
end interface
interface operator(.bar.)
  procedure foo
end interface
end module X
end


The following is invalid as there is no *explicit* interface for foo,
but it is accepted by gfortran

module X
external foo
interface nn
  procedure foo
end interface
end module X
end

NAG f95: FOO does not have an explicit interface

The following is invalid, but not rejected:

subroutine bar(a)
implicit none
interface
  subroutine a()
  end subroutine a
end interface
interface nn
  procedure a, a
  procedure a
end interface
end subroutine bar

Using "module procedure a, a" one already gets the error message:

Error: Entity 'a' at (1) is already present in the interface


The following is valid but one gets a bogus error message:
Error: Symbol at (1) is not a DUMMY variable

subroutine bar(a,b)
implicit none
interface
  subroutine a()
  end subroutine a
end interface
optional ::  a
procedure(a), optional :: b
end subroutine bar


The binding name is wrong in the following as a is a DUMMY.

subroutine foo(a)
  abstract interface
    subroutine b() bind(C)
    end subroutine b
  end interface
  procedure(b), bind(c,name="hjj") :: a
end subroutine foo



I would suggest that you reject "PROCEDURE(func)" where "func" is an
intrinsic procedure; I think one can not quickly fix it and currently it
does not work at all or wrongly. I filled PR 33162 to track this. (There
are other problems with error checking as well.)

Examples which do not work, assuming:
----------------
function my(a)
  implicit none
  double precision,intent(in) :: a
  double precision            :: my
  my = -a
end function my
----------------

a) Error: Symbol 'dcos' at (1) has no IMPLICIT type
implicit none
procedure(dcos)

b) Error: More actual than formal arguments in procedure call at (1)
implicit none
intrinsic :: dcos
procedure(dcos) :: my
print *, my(4d0)

And if one uses "my()" a REAL(4) and not a REAL(8) is expected to be
returned.


 * * *

Otherwise, I have the feeling, PROCEDUREs (w/o procedure in TYPE,
procedure pointers and the mess mentioned below) are almost ready :-)

Tobias



More information about the Fortran mailing list