Le 06/10/2022 à 10:37, Mikael Morin a écrit :
Le 05/10/2022 à 22:40, Harald Anlauf a écrit :
Hi Mikael,

Gesendet: Mittwoch, 05. Oktober 2022 um 12:34 Uhr
Von: "Mikael Morin" <morin-mik...@orange.fr>
Please move the check to resolve_transfer in resolve.cc.

I have done this, see attached updated patch.

Regtests cleanly on x86_64-pc-linux-gnu.

Strangely, the patch doesn't seem to fix the problem on the testcase
here.  There is an outer parenthese expression preventing the condition
you added from triggering.  Can you double check?

You are right: I had a one-liner in my worktree from PR105371 that
fixes an issue with gfc_simplify_merge and that seems to help here.
It is now included.

The rest looks good, but I'm not sure about your one-liner.
I will try to come with a real test later, but in principle, if you have a call to FOO(MERGE(A,A,.TRUE.)) you can't simplify it to FOO(A) as writes to the argument in FOO should not overwrite the content of A. The dummy should be associated with a temporary value, not to A.

Here is a test that your patch breaks.
Admittedly it's rejected if A has the INTENT(INOUT) attribute, but without it, I think it's allowed.

program p
  integer :: b
  b = 1
  call foo(merge(b,b,.true.))
  if (b /= 1) stop 1
contains
  subroutine foo(a)
    integer :: a
    if (a == 1) a = 42
  end subroutine foo
end program p

Reply via email to