Hi Tobias,

I am afraid we're really opening a can of worms here....

> Additionally, I wonder whether that will work with:
> 
> integer, pointer :: ptr
> integer function f()
>    pointer :: f
>    f = ptr
> end
> allocate(A, stat=f())
> 
> The f() is a variable and definable – but I am currently not sure it sets 
> stat->symtree
> and not only stat->value.function.esym, but I have not tested it.

I think a "working" testcase for this could be:

program p
  implicit none
  integer, target  :: ptr
  integer, pointer :: A
  allocate (A, stat=f())
  print *, ptr
contains
  function f()
    integer, pointer :: f
    f => ptr
  end function f
end

This works as expected with Intel and AOCC, but gives a
syntax error with every gfortran tested because of match.c:

alloc_opt_list:

      m = gfc_match (" stat = %v", &tmp);

where the comment before gfc_match states:

   %v  Matches a variable expression (an lvalue)

although it matches only variables and not every type of lvalue.
We therefore never get to the interesting checks elsewhere...

> Additionally, I have to admit that I do not understand the
> following existing condition, which you did not touch:
> 
>        if ((stat->ts.type != BT_INTEGER
>             && !(stat->ref && (stat->ref->type == REF_ARRAY
>                                || stat->ref->type == REF_COMPONENT)))
>            || stat->rank > 0)
>          gfc_error ("Stat-variable at %L must be a scalar INTEGER "
>                     "variable", &stat->where);
> 
> I mean the ts.type != BT_INTEGER and stat->rank != 0 is clear,
> but what's the reason for the refs?

Well, that needs to be answered by Steve (see commit 3759634).

[...]

> And possibly add a testcase for stat=f() [valid]
> and stat=x%y%kind [invalid] as well?

Well, I need to go back to the drawing board then...

Thanks,
Harald

Reply via email to