[Patch, fortran] PR88929 - ICE on building MPICH 3.2 with GCC 9 with ISO_Fortran_binding

Paul Richard Thomas paul.richard.thomas@gmail.com
Wed Jan 23 19:44:00 GMT 2019


The attached patch allows MPICH 3.2 to build correctly and to test successfully.

Two problems were addressed:
(i) The original implementation of ISO_Fortran_binding did not take
account of the possibility that assumed rank/assumed type arrays could
be passed as dummy arguments. This necessitated the e->rank condition
being changed to e->rank !=0 since assumed rank entities have rank ==
-1 in gfc_exprs.
(ii) Intent in requires that a copy be made of the data to be passed
to the C procedure. This is now implemented.

The testcase provides two interfaces to the C-procedure; one with
intent in and the other with intent inout. The C procedure changes the
data and so this is detected in the inout case but not in  the intent
in case. For both, the C procedure checks that the sum over the array
is correct.

>From the point of view of the release, this is completely safe since
the patch is isolated to the ISO_Fortran_binding interface, which is
newly introduced and has no effect on the rest of the testsuite. I
have bumped the testcase number by 1 to allow for a corrected version
of the withdrawn patch for the test of the errors from the CFI API
functions. I will return to this as soon as I can.

Bootstrapped and regtested on FC28/x86_64 - OK for trunk?

Paul

2019-01-23  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/88929
    * trans-array.c (gfc_conv_descriptor_elem_len): New function.
    * trans-array.h : Add prototype for above.
    * trans-expr.c (gfc_conv_gfc_desc_to_cfi_desc): Take account of
    assumed rank arrays being flagged by rank = -1 in expressions.
    Intent in arrays need a pointer to a copy of the data to be
    assigned to the descriptor passed for conversion. This should
    then be freed, together with the CFI descriptor on return from
    the C call.

2019-01-23  Paul Thomas  <pault@gcc.gnu.org>

    PR fortran/88929
    * gfortran.dg/ISO_Fortran_binding_3.f90 : New test
    * gfortran.dg/ISO_Fortran_binding_3.c : Subsidiary source.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bug1.diff
Type: text/x-patch
Size: 9595 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20190123/32476dc2/attachment.bin>


More information about the Fortran mailing list