[Patch, Fortran] PR25071 - give an error if character len of actual argument too short
Tobias Burnus
burnus@net-b.de
Thu May 3 19:49:00 GMT 2007
:ADDPATCH fortran:
This fixes part* of PR25071. An error is printed if it is known at
compile time that the character length of the actual argument is shorter
than the one of the formal argument.
Additionally, if the formal/dummy argument is a pointer or allocatable
then the length ("type parameter") needs to match exactly.
We give in both cases an error as NAG f95 does. g95 gives a warning for
the first and an error for the second. ifort and sunf95 gives an error
for the first and accepts the second without any notice.
>From the Fortran standard:
"12.4.1.2 Actual arguments associated with dummy data objects"
"The type parameter values of the actual argument shall agree with the
corresponding ones of the dummy argument that are not assumed or
deferred, except for the case of the character length parameter of an
actual argument of type default character associated with a dummy
argument that is not assumed shape."
"If a scalar dummy argument is of type default character, the length len
of the dummy argument shall be less than or equal to the length of the
actual argument. The dummy argument becomes associated with the leftmost
len characters of the actual argument. If an array dummy argument is of
type default character and is not assumed shape, it becomes associated
with the leftmost characters of the actual argument element sequence
(12.4.1.5) and it shall not extend beyond the end of that sequence."
"If the dummy argument is a pointer, the actual argument shall be a
pointer and the nondeferred type parameters and ranks shall agree. If a
dummy argument is allocatable, the actual argument shall be allocatable
and the nondeferred type parameters and ranks shall agree."
Build and regression tested with no failures but
gfortran.fortran-torture/execute/st_function.f90 (PR31095).
Ok for the trunk?
Tobias
* The unfixed part is to do the same check for arrays; here one has to
check the storage extent.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: charlen.diff
Type: text/x-patch
Size: 4137 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070503/258312f3/attachment.bin>
More information about the Fortran
mailing list