https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64958

--- Comment #9 from MarkEggleston <mark.eggleston at codethink dot com> ---
using -Wimplicit-interface helps:

    7 |     call dusty(n)
      |                 1
Warning: Procedure 'dusty' called with an implicit interface at (1)
[-Wimplicit-interface]

Adding in an interface block:

module foo
  implicit none

  interface
    subroutine dusty(n)
      integer, intent(inout) :: n
    end subroutine
  end interface

contains
  subroutine bar(n)
    integer, intent(in) :: n
    print *,"bar before dusty", n
    call dusty(n)
    print *,"bar after dusty", n
  end subroutine bar

end module foo

program main
  use foo
  implicit none
  integer :: n
  n = 5
  call bar(6)
end program main

subroutine dusty(n)
  integer :: n
  n = n - 1
end

Resulting in two errors:

   14 |     call dusty(n)
      |               1
Error: Dummy argument 'n' with INTENT(IN) in variable definition context
(actual argument to INTENT = OUT/INOUT) at (1)
here
pr64598.f90:21:6:

   21 |   use foo
      |      1
Fatal Error: Cannot open module file 'foo.mod' for reading at (1): No such file
o

If intent(inout) is omitted from the interface block the program will compile
with the fault unidentified. I'm working on a patch that will warn about
modification of dummy variables that have no intent which will warn in this
case. (PR fortran/88079).

Reply via email to