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

--- Comment #8 from Thomas Koenig <tkoenig at gcc dot gnu.org> ---
As long as we use a single file, it would be possible to
warn about this.

What we could do is to analyze dusty and check that its argument
n may be redefined. If it appears in a variable definition
context, we could set it to a new intent like INTENT_UNKNOWN_REDEFINED,
which would for all intents and purposes be treated like INTENT_UNKNOWN
except that we would warn if such an argument were passed a
constant, or if it is passed an INTENT(OUT) variable.

This would not even break our module format.

We already warn for

subroutine rusty(n)
  integer, intent(out) :: n
end

module foo
  implicit none
contains
  subroutine bar(n)
    integer, intent(in) :: n
    print *,"bar before rusty", n
    call rusty(n)
    print *,"bar after rusty", n
  end subroutine bar
end module foo

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

so most of the machinery is in place already.

Reply via email to