[Patch, Fortran, OOP] PR 54784: [4.7/4.8 Regression] wrong code in polymorphic allocation with SOURCE

Janus Weil janus@gcc.gnu.org
Thu Oct 11 15:41:00 GMT 2012


Hi Mikael,

>> here is a small patch for a wrong-code regression with polymorphic
>> allocation. The problem is that we falsely detect the allocation
>> variable to be a polymorphic array (although it is a scalar). For
>> further details see the PR, in particular comment 4.
>>
>> Regtested on x86_64-unknown-linux-gnu. Ok for trunk and 4.7?
> Hello, the fix looks incomplete.
>
>>
>> Index: gcc/fortran/trans-stmt.c
>> ===================================================================
>> --- gcc/fortran/trans-stmt.c  (revision 192004)
>> +++ gcc/fortran/trans-stmt.c  (working copy)
>> @@ -5145,7 +5145,9 @@ gfc_trans_allocate (gfc_code * code)
>>             dataref = actual->next->expr->ref;
>>             /* Make sure we go up through the reference chain to
>>                the _data reference, where the arrayspec is found.  */
>> -           while (dataref->next && dataref->next->type != REF_ARRAY)
>> +           while (!(dataref->type == REF_COMPONENT
>> +                    && strcmp (dataref->u.c.component->name, "_data") == 0)
>> +                  && dataref->next)
> this stops on the first class reference, while it seems to me that it
> should stop on the last.

thanks for the review and sorry for taking so long to come back to it.

In fact I did not manage to come up with a test case where the patch
would fail, but maybe I just did not try hard enough. In any case,
please find attached a new version of the patch, which should make
sure to catch the *last* _data reference, not the first one.

Will commit to trunk after another regtest (and to 4.7 after a few
days). If you still see any problems with the patch, please let me
know.

Cheers,
Janus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr54784_v2.diff
Type: application/octet-stream
Size: 1241 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20121011/c34983f9/attachment.obj>


More information about the Gcc-patches mailing list