This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] fortran/45495 -- optional dummy args cannot not be in restricted expressions
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Tobias Burnus <tobias dot burnus at physik dot fu-berlin dot de>
- Cc: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 3 Sep 2010 12:13:39 -0700
- Subject: Re: [PATCH] fortran/45495 -- optional dummy args cannot not be in restricted expressions
- References: <20100903174436.GA18566@physik.fu-berlin.de>
On Fri, Sep 03, 2010 at 07:44:36PM +0200, Tobias Burnus wrote:
> Steve Kargl wrote:
> > Including a check for intent(out) causes
> > FAIL: gfortran.dg/spec_expr_2.f90 -O (test for excess errors)
> > FAIL: gfortran.fortran-torture/compile/inquiry_1.f90, -O2 -fomit-frame-pointer
> >
> > troutmask:kargl[203] cat spec_expr_2.f90
> > ! { dg-do compile }
> > ! PR 22273: Allow INTENT(OUT) dummy:s as arguments to LEN() in specification
>
> OK, a simple check won't do. But I believe my test case is still invalid:
>
> character(len=len(str(1:a))+1) :: b
>
> The issue is that "a" is not a string whose length is queried but that the
> value of "a" itself is used - which is undefined if "a" is INTENT(OUT).
>
>
> > Anyway, I'm confident that my original optional patch is correct.
>
> I concur. Thus, go ahead with that part.
>
>
> > Inclusion of intent(out) seems to go against (7)(b)(iii) in that
> > the property being inquired about is the length of the string.
>
> To quote only the relevant part of F2008's "7.1.11 Specification expression"
> (with cutting out irrelevant parts and adding a comment in brackets):
>
> "A restricted expression is an expression in which each primary is
> a specification inquiry [such as "LEN"] where each designator or function
> argument is a restricted expression or a variable whose properties inquired
> about are not defined by an expression that is not a restricted expression"
>
> I think the standard is pretty clear:
> While "len(str)" and "str" are restricted expressions, "str(1:a)" is not;
> thus, one should allow len(str) - even if "str" is INTENT(OUT) - but one
> should reject "str(1:a)" - if "a" is INTENT(OUT).
>
I may have a fix the intent(out) issue as well. I testing it now.
--
Steve