[Patch, fortran] PR98498 - Interp request: defined operators and unlimited polymorphic

Harald Anlauf anlauf@gmx.de
Thu Nov 2 20:35:26 GMT 2023


Hi Paul,

Am 02.11.23 um 19:18 schrieb Paul Richard Thomas:
> Hi Harald,
>
> I was overthinking the problem. The rejected cases led me to a fix that can
> only be described as a considerable simplification compared with the first
> patch!

this patch is *much* simpler, makes more sense, and works here. :-)

> The testcase now reflects the requirements of the standard and
> regtests without failures.
>
> OK for mainline?

Yes, OK for mainline.

Thanks,
Harald

> Thanks
>
> Paul
>
> Fortran: Defined operators with unlimited polymorphic args [PR98498]
>
> 2023-11-02  Paul Thomas  <pault@gcc.gnu.org>
>
> gcc/fortran
> PR fortran/98498
> * interface.cc (upoly_ok): Defined operators using unlimited
> polymorphic formal arguments must not override the intrinsic
> operator use.
>
> gcc/testsuite/
> PR fortran/98498
> * gfortran.dg/interface_50.f90: New test.
>
>
> On Wed, 1 Nov 2023 at 20:12, Harald Anlauf <anlauf@gmx.de> wrote:
>
>> Hi Paul,
>>
>> Am 01.11.23 um 19:02 schrieb Paul Richard Thomas:
>>> The interpretation request came in a long time ago but I only just got
>>> around to implementing it.
>>>
>>> The updated text from the standard is in the comment. Now I am writing
>>> this, I think that I should perhaps use switch(op)/case rather than using
>>> if/else if and depending on the order of the gfc_intrinsic_op enum being
>>> maintained. Thoughts?
>>
>> the logic is likely harder to parse with if/else than with
>> switch(op)/case.  However, I do not think that the order of
>> the enum will ever be changed, as the module format relies
>> on that very order.
>>
>>> The testcase runs fine with both mainline and nagfor. I think that
>>> compile-only with counts of star-eq and star_not should suffice.
>>
>> I found other cases that are rejected even with your patch,
>> but which are accepted by nagfor.  Example:
>>
>>      print *, ('a' == c)
>>
>> Nagfor prints F at runtime as expected, as it correctly resolves
>> this to star_eq.  Further examples can be easily constructed.
>>
>> Can you have a look?
>>
>> Thanks,
>> Harald
>>
>>> Regtests with no regressions. OK for mainline?
>>>
>>> Paul
>>>
>>> Fortran: Defined operators with unlimited polymorphic args [PR98498]
>>>
>>> 2023-11-01  Paul Thomas  <pault@gcc.gnu.org>
>>>
>>> gcc/fortran
>>> PR fortran/98498
>>> * interface.cc (upoly_ok): New function.
>>> (gfc_extend_expr): Use new function to ensure that defined
>>> operators using unlimited polymorphic formal arguments do not
>>> override their intrinsic uses.
>>>
>>> gcc/testsuite/
>>> PR fortran/98498
>>> * gfortran.dg/interface_50.f90: New test.
>>>
>>
>>
>



More information about the Fortran mailing list