This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [patch, fortran] Fix PR41235, accepts invalid
Daniel Franke wrote:
> Ignore the last patch, try this updated one instead. The place in
> interface.c
> was wrong and the required check is actually already present in resolve.c
> (resolve_fl_procedure) - it just didn't apply in the reporters case. Changed
> to check for unknown interfaces instead of explicitely marked external
> procedures - the entry_master check is to silence entry_17.f90.
>
> Regression tested on i686-pc-linux-gnu. Ok for trunk (with updated ChangeLog
> and testcase from PR)?
>
I am not sure that the patch is correct. I think one refers to the
following item in the standard:
"A procedure [...] shall have an explicit interface if it is referenced and
[...]
(3) The procedure has a result that [...]
(c) has a nonassumed type parameter value that is not an initialization
expression,"
But I think the following code would be valid in this regard (although only NAG f95 compiles it; g95, openf95, ifort reject it).
character(len=*) function func()
func = 'ABC'
end function func
subroutine test(i)
integer :: i
character(len=i), external :: func ! (1)
! character(len=i) :: func ! (2)
print *, func()
end subroutine test
call test(2)
end
The assumed length character functions are deprecated (= small print) in Fortran 2003/2008 but still not deleted. The example (1) is already rejected with the current trunk gfortran, the version (2) only with your patch.
The true solution is to do what NAG f95 does for the invalid example in the PR: Only issue an error, if one knows that the function does not have an assumed-type parameter.
Tobias