In the following program, the interface of the dummy procedure is explicit.

Fortran 2003's "12.4.1.3 Actual arguments associated with dummy procedure
entities" has about this:

"If the interface of the dummy argument is explicit, the characteristics listed
in 12.2 shall be the same for the associated actual argument and the
corresponding dummy argument, except that a pure actual argument may be
associated with a dummy argument that is not pure and an elemental intrinsic
actual procedure may be associated with a dummy procedure (which is prohibited
from being elemental)."

"If an external procedure name or a dummy procedure name is used as an actual
argument, its interface shall be explicit or it shall be explicitly declared to
have the EXTERNAL attribute."


gfortran does not seem to check whether the array arguments of dummy procedures
match. One reason could be that passing a "a(2)" array ("call foo(a)") to an
array "a(:)" is valid, but this does not apply here.

For some reason, gfortran checks this for
  PROCEDURE(<interface>) :: dummy
but not for
  INTERFACE; subroutine dummy() ...
in principle I had expected that both is handled identically. Remove the "!!"
to test the PROCEDURE version.

Found at
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/330df81363912681

Please also check the version given there (incl. the PROCEDURE version) when
fixing this PR.

program test
  implicit none
  interface
    subroutine one(a)
      integer a(:)
    end subroutine one
    subroutine two(a)
      integer a(2)
    end subroutine two
  end interface
  ! PROCEDURE dummy, gives error:
  !! call foo(two)    ! OK: "Type/rank mismatch in argument 'f'"
  ! Interface dummy, is accepted:
  call bar(two)  ! Invalid, not diagnosed
contains
! Valid, but gives an ICE in trans-*.c, see PR 35830
!!  subroutine foo(f)
!!    procedure(one) :: f
!!  end subroutine foo

  subroutine bar(f)
    interface
      subroutine f(a)
        integer a(:)
      end subroutine f
    end interface
  end subroutine bar
end program test


-- 
           Summary: Type-mismatch check missing for dummy procedure argument
           Product: gcc
           Version: 4.4.0
            Status: UNCONFIRMED
          Keywords: accepts-invalid
          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=35831

Reply via email to