[Patch, Fortran] PR32616 - Add more actu./form. argument checks

Tobias Burnus burnus@net-b.de
Thu Jan 17 09:15:00 GMT 2008


This fix a typo and adds a bunch of argument checks:

a) The string length needs to match exactly not only if the dummy
argument is a pointer or allocatable, but also if the dummy is an
assumed-shape array:

"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." (12.4.1.2)


b) If one specifies an array element, a warning is now printed if the
storage size of the array (starting from the array index and the lower
bound of the substring) is smaller than the requested storage size of
the dummy argument.
There were already some tests before, but now also array elements are
checked.


c) Regarding the typo: It is indeed INTENT(OUT); the check above is:
      if ((f->sym->attr.intent == INTENT_OUT
           || f->sym->attr.intent == INTENT_INOUT
           || f->sym->attr.volatile_)
and the standard mandates: "If the actual argument is an array section
having a vector subscript, the dummy argument is not definable and shall
not have the INTENT(OUT), INTENT(INOUT), VOLATILE, or ASYNCHRONOUS
attributes." (12.4.1.2)


(Note: (b) only prints a warning; thus we will never reject a valid
program if I missed something [I'm quite confident that I didn' ;-)].)

Build and regression tested on x86-64-linux.
OK for the trunk?

Tobias
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: argcheck.diff
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20080117/12df7865/attachment.ksh>


More information about the Fortran mailing list