[Bug fortran/88079] warn about procedure arguments without INTENT
mark.eggleston at codethink dot com
gcc-bugzilla@gcc.gnu.org
Mon Jul 1 12:49:00 GMT 2019
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88079
--- Comment #5 from MarkEggleston <mark.eggleston at codethink dot com> ---
Given the program below:
program main
implicit none
integer :: n
n = 5
call bar(n)
end program main
subroutine bar(n)
integer, intent(in) :: n
real :: x
print *,"bar before dusty", n
call dusty(n)
print *,"bar after dusty", n
end subroutine bar
subroutine dusty(n)
integer :: n
n = n - 1
end
the attached patch produces the following warnings:
pr88079_2.f90:19:2:
19 | n = n - 1
| 1
Warning: Dummy variable 'n' in assignment at (1) has missing INTENT or VALUE
[-Wintent]
pr88079_2.f90:13:15:
13 | call dusty(n)
| 1
Warning: Dummy variable 'n' at (1) has INTENT(IN) and may be modified
[-Wintent]
pr88079_2.f90:17:18:
17 | subroutine dusty(n)
| 1
Warning: Dummy variable 'n' in assignment at (1) has missing INTENT or VALUE
[-Wintent]
Note: if compiles with a standard earlier than Fortran 2003 "or VALUE" will be
omitted.
I'm not happy with the location of the last warning which is why it is worded
as it is. I would prefer the following:
18 | integer :: n
| 1
Warning: Missing INTENT or VALUE at (1)
I currently don't know enough about identifying the location of a warning or
error to determine whether this can be done.
Where dusty(n) is called the interface to dusty is known, however, this is not
always the case so the attribute of the associate dummy variable can always be
checked. To help identify a potential problem -Wimplicit-inteface can be used.
More information about the Gcc-bugs
mailing list