This is the mail archive of the mailing list for the GNU Fortran project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] fortran/45495 -- optional dummy args cannot not be in restricted expressions

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).


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]