This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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, OOP] PR 44962: [OOP] ICE with specification expression SIZE(<CLASS>)


Hi Janus,

Janus Weil wrote:
>> Frankly, I do not quite understand the check. [...]
>>     
> Well, in general array bounds are only required to be specification
> expressions (F08:R516-518). However, there is an additional
> constraint. In F03 it was:
>
> C542 (R511) An explicit-shape array whose bounds are not
> initialization expressions shall be a dummy argument, a function
> result, or an automatic array of a procedure.
>
> In F08 it is:
>
> C531 (R516) An explicit-shape-spec whose bounds are not constant expressions shall appear only in a subprogram, derived type definition, BLOCK construct, or interface body.
>   

Can you add a comment before the gfc_is_constant_expr to state what the
function is actually doing (e.g. checking for specification expressions
while taking additionally the given constraints into account.)

> If I am interpreting the above restrictions correctly, then components
> had to have constant array bounds in F03, while in F08 they don't have
> to be constant. Is that right?

Seems so, but I somehow do not understand how this is supposed to work;
probably somehow like:

subroutine foo(n)
  type t
    integer :: a(n)
  end type t
...
end


> Good point. So, what do you think about this new version of the patch?
> I will regtest it now ...
>   

Somehow also the references look wrong. If I look at

check_specification_function

it claims that this is: "F95, 7.1.6.2; F2003, 7.1.7", but F2003's 7.1.7
is about initialization expressions; I assume it should be 7.1.6
(specification expressions).
(Please correct as well.)

As you check for specification expressions, you cannot simply remove the
check. The reason is that check_specification_function excludes
intrinsic functions (cf. "specification function" in the standard).
Thus, you still need to check for:

(7) A specification inquiry where each designator or function argument
is [...]
(8) A reference to any other standard intrinsic function where each
argument is a restricted expression,

I do not think that one needs to exclude the random functions (who says
that the array size needs to be deterministic). But I still do not
understand why there is currently a check for having minimally a single
argument.

Regarding your example: It seems to be valid in F2008 (assuming that
"irand()" is regarded as specification expression) but it seems to be
invalid in F2003 due to C542...

I think allowing non-constant local types will be fun for extensible
types and dynamic types, which - using BLOCK and internal functions one
can easily use.

Tobias


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