Hi Mikael, hi all,
Mikael Morin wrote:
index f135af1..6c58a8e 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -8319,12 +8323,15 @@ gfc_walk_array_ref (gfc_ss * ss, gfc_expr *
expr, gfc_ref * ref)
break;
case AR_FULL:
- newss = gfc_get_array_ss (ss, expr, ar->as->rank,
GFC_SS_SECTION);
+ newss = gfc_get_array_ss (ss, expr,
+ ar->as->rank < 0 ? GFC_MAX_DIMENSIONS
+ : ar->as->rank,
+ GFC_SS_SECTION);
newss->info->data.array.ref = ref;
/* Make sure array is the same as array(:,:), this way
we don't need to special case all the time. */
- ar->dimen = ar->as->rank;
+ ar->dimen = ar->as->rank < 0 ? GFC_MAX_DIMENSIONS : ar->as->rank;
for (n = 0; n < ar->dimen; n++)
{
ar->dimen_type[n] = DIMEN_RANGE;
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
I would rather avoid that if possible.
Maybe it is. However, the following has to work:
- ubound(assumed_rank, dim=i), ditto for lbound
- size(ar), size(ar, dim=i)
(That works with the current patch.) Furthermore, but unsupported, the
following has to work:
- ubound(ar), lbound(ar) and shape(ar)
- Passing a class-actual assumed-rank variable to a derived-type
assumed-rank dummy argument. (Required for packing - at least if the
dummy is contiguous).
And for internal use for the FINAL wrapper function, but invalid
according to the Technical Specification:
- call elemental_subroutine(ar)
The scalarizer assumes the rank is known, and all hell breaks loose if
it's not the case.
After quickly browsing through TS29113, I couldn't tell whether
expressions like (ar + 1) would be valid as assumed rank actual argument.
No, you are only allowed to do very few things with assumed rank arrays:
* Passing them as first argument to the intrinsic inquiry functions like
PRESENT, ALLOCATED, ASSOCIATED, UBOUND, LBOUND, SHAPE and SIZE. (And
some more like KIND but they aren't interesting.)
* Passing them to an assumed-rank procedure. (Here, allowed are:
class->type, type->class, class->class, type->type and also
non-simply-contiguous -> CONTIGUOUS, which implies a packing for the
argument).
* As first argument to C_LOC
All other impressions and anything like "ar(:)" or "ar(1)" etc. aren't
allowed.
In case it's not, then everything is fine I guess, though I prefer
avoiding polluting the scalarizer with assumed rank stuff ;-).
It still will get worse, see above. Though, I wouldn't mind if you could
modify the scalarizer. My next patch will be to pass scalars to assumed
rank. It is mostly done, but it still has some issues.
Tobias
PS: I will reply later to the other issues raised in your review.