This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, fortran] PR18578, PR18579, PR20857 and PR20885 - Constraints on INTENT(OUT and INOUT)
- From: Paul Brook <paul at codesourcery dot com>
- To: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- Cc: gcc-patches at gcc dot gnu dot org, Paul Thomas <paulthomas2 at wanadoo dot fr>, "'fortran at gcc dot gnu dot org'" <fortran at gcc dot gnu dot org>
- Date: Sat, 18 Feb 2006 18:56:10 +0000
- Subject: Re: [Patch, fortran] PR18578, PR18579, PR20857 and PR20885 - Constraints on INTENT(OUT and INOUT)
- Organization: CodeSourcery
- References: <43DC66F8.50306@wanadoo.fr> <200601291213.35379.paul@codesourcery.com> <20060218183518.GA80732@troutmask.apl.washington.edu>
On Saturday 18 February 2006 18:35, Steve Kargl wrote:
> On Sun, Jan 29, 2006 at 12:13:34PM +0000, Paul Brook wrote:
> > On Sunday 29 January 2006 06:55, Paul Thomas wrote:
> > > This patch implements the obvious constraints on the use of INTENT(OUT
> > > and INOUT). ie: that the actual argument should be a variable
> > > ("definable" in the standard) and that INTENT(OUT) variables should be
> > > defined or intialized before they are used or before return from the
> > > procedure.
> >
> > Variables that aren't defined should be caught be the normal unused
> > parameter/variable warnings. AFAIK there's nothing special about
> > INTENT(OUT) that requires it be defined.
>
> pault is almost quoting the language from the standard. See page 53.
>
> The INTENT(OUT) attribute specifies that the dummy argument shall
> be defined before a reference to the dummy argument is made within
> the procedure and any actual argument that becomes associated with
> such a dummy argument shall be definable. On invocation of the
> procedure, such a dummy argument becomes undefined except for
> components of an object of derived type for which default
> initialization has been specified.
>
> The INTENT(INOUT) attribute specifies that the dummy argument is
> intended for use both to receive data from and to return data to
> the invoking scoping unit. Any actual argument that becomes
> associated with such a dummy argument shall be definable.
There are two issues:
a) Actual arguments for intent(out) dummy arguments must be definable. This is
fine.
b) intent(out) dummy arguments must be defined before the function returns. I
don't see anything in the standard that requires this. AFAICS this is only
illegal if the caller tries to reference the corresponding actual argument
after the call.
Paul