[Patch, fortran] PR27124 - Incorrect dependency for assignment from function with array section actual arg.

Paul Thomas paulthomas2@wanadoo.fr
Wed Apr 12 19:19:00 GMT 2006


:ADDPATCH fortran:

Please find below the patch to fix and the test case for PR27124, 
submitted by Philippe Schaffnit, yesterday.

As described in the bug report, the problem arises because the unpacking 
of an array section actual argument overwrites the result, which itself 
is written from a temporary.  The correction of the problem requires 
that these two operations occur in the opposite order.

Quite simply, the fix consists of gathering up all the argument 
post_blocks, which contain the unpacking and freeing of argument 
temporaries, and stashing them into a separate block. After the function 
call is translated, its expression either goes in the se->pre block or 
becomes the se->expr, depending on how the value is returned. Depending 
on this same choice, we now add the argument post block to se->pre or to 
se->post. This ensures that the results of byref calls that produce 
temporaries are transferred to the destination array AFTER the unpacking 
of the argument because they go to the se->post block directly. The 
reduced testcase below now runs correctly.

The patch and testcase appear below.

Regtested on Cygwin_NT/PIV and FC3/Athlon.  OK for trunk and 4.1?

Paul

2006-04-12  Paul Thomas  <pault@gcc.gnu.org>

    * trans_expr.c (gfc_trans_function_call):  Add a new block, post, in to
    which all the argument post blocks are put.  Add this block to se->pre
    after a byref call or to se->post, otherwise.
   
2006-04-12  Paul Thomas  <pault@gcc.gnu.org>

    * gfortran.dg/array_return_value_1.f90: New test.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: array_val.diff
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060412/5b740a5f/attachment.ksh>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: array_return_value_1.f90
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060412/5b740a5f/attachment.f90>


More information about the Gcc-patches mailing list