Hi Sandra,

Am 02.01.22 um 19:32 schrieb Sandra Loosemore:
This patch is for PR103390.  For background on this issue, the Fortran
standard requires that, when passing a non-contiguous array from Fortran
to a BIND(C) function with the CONTIGUOUS attribute on the corresponding
dummy argument, the compiler has to arrange for it to be copied to/from
a contiguous temporary.  The ICE was happening because the front end was
attempting to copy out to an array-valued expression that isn't an
lvalue, and producing invalid code.

I poked around at several related examples (included as test cases in
the patch) and realized that it should not be doing any copying at all
here, since the expression result already was being put in a contiguous
temporary.  And, besides the invalid code on copy-out, in some cases it
was generating multiple copies of the code to compute the expression on
copy-in.  :-S

Both parts of the patch seem to be necessary to fix all the test cases.
Tobias pointed me in this direction when I discussed it with him a few
weeks ago so I hope I got it right.

OK to check in?  It regression-tests fine on x86_64.

LGTM.

There are a few really minor things to improve:

+       /* TRANPOSE is the only intrinsic that may return a

s/TRANPOSE/TRANSPOSE/

+! We only expect one loop before the call, to fill in the contigous

s/contigous/contiguous/

+! { dg-final { scan-tree-dump-times "contiguous\\.\[0-9\]+" 0
"original" } }

There is a shorter, slightly shorter form for absence of a pattern:

! { dg-final { scan-tree-dump-not "contiguous\\.\[0-9\]+" "original" } }

-Sandra

Thanks for the patch!

Reply via email to