]> git.ipfire.org Git - thirdparty/gcc.git/commit
fortran: Move clobbers after evaluation of all arguments [PR106817]
authorMikael Morin <mikael@gcc.gnu.org>
Sat, 3 Sep 2022 09:58:47 +0000 (11:58 +0200)
committerMikael Morin <mikael@gcc.gnu.org>
Sun, 25 Sep 2022 12:44:53 +0000 (14:44 +0200)
commit29919bf3b6449bafd02e795abbb1966e3990c1fc
tree9d7cb942bb55c967647750a6e632369b19ebda87
parentedaf1e005c90b311c39b46d85cea17befbece112
fortran: Move clobbers after evaluation of all arguments [PR106817]

For actual arguments whose dummy is INTENT(OUT), we used to generate
clobbers on them at the same time we generated the argument reference
for the function call.  This was wrong if for an argument coming
later, the value expression was depending on the value of the just-
clobbered argument, and we passed an undefined value in that case.

With this change, clobbers are collected separatedly and appended
to the procedure call preliminary code after all the arguments have been
evaluated.

PR fortran/106817

gcc/fortran/ChangeLog:

* trans-expr.cc (gfc_conv_procedure_call): Collect all clobbers
to their own separate block.  Append the block of clobbers to
the procedure preliminary block after the argument evaluation
codes for all the arguments.

gcc/testsuite/ChangeLog:

* gfortran.dg/intent_optimize_4.f90: New test.
gcc/fortran/trans-expr.cc
gcc/testsuite/gfortran.dg/intent_optimize_4.f90 [new file with mode: 0644]