Daniel Carrera wrote:
I propose this:


if (!gfc_array_allocate (&se, expr, stat, errmsg, errlen))
  {
    ... allocate scalar ...
  }
if (code->expr1)
  {
    /* The coarray library already sets the errmsg.  */
    if (gfc_option.coarray == GFC_FCOARRAY_LIB
&& gfc_expr_attr (expr).codimension)
      tmp = build1_v (GOTO_EXPR, label_finish);
    else
      tmp = build1_v (GOTO_EXPR, label_errmsg);
    ...
  }

Yes, that was what I was thinking of. I hadn't checked whether one could use exactly the same code or needed a slightly different version, but it seems as if one can do just as you have written.

[Other PR]
I think I even remember noticing that the code deallocated the previous array and was wondering why it did that.

I think I saw the code also before in some dump, wondered about it, but not enough to check the standard, which explicitly prohibits the (de/re)allocation. (It does so in F2003 and F2008, I have not checked the wording in F90/F95. Maybe the status back then was "undefined"?)

Tobias

Reply via email to