Re: *PING**2 – Re: [Patch] Fortran: Fix Bind(C) char-len check, add ptr-contiguous check

Paul Richard Thomas paul.richard.thomas@gmail.com
Tue Aug 31 06:09:36 GMT 2021


Hi Tobias,

s/However, as argument they are also iteroperable/However, as an argument
they are also interoperable/

s/ /* else: valid only sind F2018 - and an assumed-shape/rank
    array; however, gfc_notify_std is already called when
    those array type are used. Thus, silently accept F200x. */ /
  /* else: valid only since F2018 - and an assumed-shape/rank
    array; however, gfc_notify_std is already called when
    those array types are used. Thus, silently accept F200x. */

Apart from those nits, it looks good to me. It even regtests OK :-)

Thanks for sorting out the standard-ese. OK for mainline and, I would
suggest 11-branch.

Cheers

Paul


On Sun, 29 Aug 2021 at 08:35, Tobias Burnus <burnus@net-b.de> wrote:

> PING**2
>
> On 25.08.21 20:58, Tobias Burnus wrote:
> > Early *PING*.
> > (I also should still review several Fortan patches... There are lots of
> > patches waiting for review :-/)
> >
> > On 20.08.21 19:24, Tobias Burnus wrote:
> >> The following is about interoperability (BIND(C)) only.
> >>
> >>
> >> * The patch adds a missing check for pointer + contiguous.
> >> (Rejected to avoid copy-in issues? Or checking issues?)
> >>
> >>
> >> * And it corrects an issue regarding len > 1 characters. While
> >>
> >>  subroutine foo(x)
> >>     character(len=2) :: x(*)
> >>
> >> is valid Fortran code (the argument can be "abce" or ['a','b','c','d']
> >> or ...)
> >> – and would work also with bind(C) as the len=2 does not need to be
> >> passed
> >> as hidden argument as len is a constant.
> >> However, it is not valid nonetheless.
> >>
> >>
> >> OK? Comments?
> >>
> >> Tobias
> >>
> >>
> >> PS: Referenced locations in the standard (F2018):
> >>
> >> C1554 If proc-language-binding-spec is specified for a procedure,
> >> each of its dummy arguments shall be an interoperable procedure (18.3.6)
> >> or a variable that is interoperable (18.3.4, 18.3.5), assumed-shape,
> >> assumed-rank, assumed-type, of type CHARACTER with assumed length,
> >> or that has the ALLOCATABLE or POINTER attribute.
> >>
> >> 18.3.1: "... If the type is character, the length type parameter is
> >> interoperable if and only if its value is one. ..."
> >>
> >> "18.3.4 Interoperability of scalar variables":
> >> "... A named scalar Fortran variable is interoperable ... if it
> >> is of type character12its length is not assumed or declared by
> >> an expression that is not a constant expression."
> >>
> >> 18.3.5: Likewise but for arrays.
> >>
> >> 18.3.6 "... Fortran procedure interface is interoperable with a C
> >> function prototype ..."
> >> "(5) any dummy argument without the VALUE attribute corresponds
> >>      to a formal parameter of the prototype that is of a pointer type,
> >> and either
> >>      • the dummy argument is interoperable with an entity of the
> >> referenced type ..."
> >> (Remark: those are passed as byte stream)
> >>      "• the dummy argument is a nonallocatable nonpointer variable of
> >> type
> >>         CHARACTER with assumed character length and the formal
> >> parameter is
> >>         a pointer to CFI_cdesc_t,
> >>       • the dummy argument is allocatable, assumed-shape,
> >> assumed-rank, or
> >>         a pointer without the CONTIGUOUS attribute, and the formal
> >> parameter
> >>         is a pointer to CFI_cdesc_t, or
> >> (Remark: those two use an array descriptor, also for
> >> explicit-size/assumed-size
> >> arrays or for scalars.)
> >>       • the dummy argument is assumed-type ..."
> >>
> > -----------------
> > Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße
> > 201, 80634 München; Gesellschaft mit beschränkter Haftung;
> > Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft:
> > München; Registergericht München, HRB 106955
>


-- 
"If you can't explain it simply, you don't understand it well enough" -
Albert Einstein


More information about the Gcc-patches mailing list