This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [Patch, Fortran] PR 41714: [OOP] ALLOCATE SOURCE= does not properly copy the value from SOURCE
>>> It looks OK to me except:
>>>
>>>> ? ? ? ?PR fortran/41714
>>>> ? ? ? ?* trans-expr.c (gfc_build_memcpy_call): Take care of the case that the
>>>> ? ? ? ?call to '__builtin_memcpy' is optimized away (replaced by a direct
>>>> ? ? ? ?assignment).
>>>
>>> How the heck does that work? ?It comes out as a NOP_EXPR and yet it's
>>> really an assignment..... Is that documented somewhere?
>>
>> That patch looks indeed dubious. ?It tests for an implementation detail
>> (the memcpy folder returns (void *) ({ *dst = *src; dst; })). ?You should
>> be able to unconditionally fold-convert to void_type_node as in the
>> original code. ?Instead tree_annotate_all_with_location should be fixed.
>
> Or rather the FE should not call this function - it assumes that the code
> is already gimplified.
Ok, so you mean one should instead just do the stuff which this
function does, but without the extra checks? Like here:
Index: gcc/fortran/trans.c
===================================================================
--- gcc/fortran/trans.c (Revision 153538)
+++ gcc/fortran/trans.c (Arbeitskopie)
@@ -1282,7 +1282,11 @@ gfc_trans_code (gfc_code * code)
if (res != NULL_TREE && ! IS_EMPTY_STMT (res))
{
if (TREE_CODE (res) == STATEMENT_LIST)
- tree_annotate_all_with_location (&res, input_location);
+ {
+ tree_stmt_iterator i;
+ for (i = tsi_start (res); !tsi_end_p (i); tsi_next (&i))
+ SET_EXPR_LOCATION (tsi_stmt (i), input_location);
+ }
else
SET_EXPR_LOCATION (res, input_location);
Note: Maybe one should rather use 'tree_annotate_one_with_location'
instead of SET_EXPR_LOCATION, but right now this is static in
gimplify.c.
Cheers,
Janus