[Patch, Fortran] PR 44207: ICE with ALLOCATABLE components and SOURCE

Janus Weil janus@gcc.gnu.org
Thu Jun 10 23:03:00 GMT 2010


>> resolve.c has conformable_arrays and compare_shapes that both seem to do about
>> the same. Could they be merged?
>
> well, I don't know. I had seen your comment in the PR earlier, but
> firstly I'm not sure if they really do exactly the same (and if they
> are supposed to), and secondly the error messages in
> conformable_arrays are specifically targeted at the SOURCE
> expressions. So I guess it would at least take some effort to merge
> them, if it makes sense at all.

Ok, I had a closer look at this, and I'd conclude that both functions
basically are supposed to check for the same things, but for the check
on ALLOCATE (..., SOURCE=...) one has to do some extra work.

The reason for this is that when parsing something like

allocate(arr(5),source=...)

we get an expression that has an AR_ELEMENT instead of an AR_SECTION,
although we technically make an assignment to arr(1:5) when using
SOURCE=....

The extra bits in conformable_arrays extract the correct rank and
shape out of the AR_ELEMENT expression (which technically is a
scalar).


Btw, both 'conformable_arrays' and 'compare_shapes' were implemented
by Steve (the first in r151023, the second in r95945), so maybe he can
give some advice here?


Maybe an alternative approach to ALLOCATE would be to convert the
AR_ELEMENT to an AR_SECTION right when parsing it, so that all
following stuff can operate on the whole array, and not on something
that looks like a scalar. I don't know if that is feasible, though.


> For a start, I wanted to get conformable_arrays fixed. One could still
> think about merging them afterwards.

Due to the complications described above it is not trivial to merge
both functions, and I would prefer to just fix the ICE with the patch
I proposed earlier in this thread. Is that ok?

Cheers,
Janus



More information about the Fortran mailing list