[PATCH] Fortran: passing of optional dummies to elemental procedures [PR113377]
Mikael Morin
morin-mikael@orange.fr
Wed Jan 24 18:46:30 GMT 2024
Le 23/01/2024 à 21:36, Harald Anlauf a écrit :
> Dear all,
>
> here's the second part of a series for the treatment of missing
> optional arguments passed to optional dummies, now fixing the
> case that the latter procedures are elemental. Adjustments
> were necessary when the missing dummy has the VALUE attribute.
>
> I factored the code for the treatment of VALUE, hoping that the
> monster loop in gfc_conv_procedure_call will become slightly
> easier to overlook.
>
> Regtested on x86_64-pc-linux-gnu. OK for mainline?
>
Looks good, but...
> Thanks,
> Harald
>
>
> diff --git a/gcc/fortran/trans-expr.cc b/gcc/fortran/trans-expr.cc
> index 128add47516..0fac0523670 100644
> --- a/gcc/fortran/trans-expr.cc
> +++ b/gcc/fortran/trans-expr.cc
> @@ -6392,12 +6479,23 @@ gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
> }
> }
>
> + /* Scalar dummy arguments of intrinsic type with VALUE attribute. */
> + if (fsym
> + && fsym->attr.value
> + && !fsym->attr.dimension
> + // && (fsym->ts.type != BT_CHARACTER
> + // || gfc_length_one_character_type_p (&fsym->ts))
... please remove the commented code here. OK with that change.
The !fsym->attr.dimension condition could be removed as well as we are
in the case of an elemental procedure at this point, but it doesn't harm
if you prefer keeping it.
Thanks for the patch.
Mikael
> + && fsym->ts.type != BT_DERIVED
> + && fsym->ts.type != BT_CLASS)
> + conv_dummy_value (&parmse, e, fsym, optionalargs);
> +
> /* If we are passing an absent array as optional dummy to an
> elemental procedure, make sure that we pass NULL when the data
> pointer is NULL. We need this extra conditional because of
> scalarization which passes arrays elements to the procedure,
> ignoring the fact that the array can be absent/unallocated/... */
> - if (ss->info->can_be_null_ref && ss->info->type != GFC_SS_REFERENCE)
> + else if (ss->info->can_be_null_ref
> + && ss->info->type != GFC_SS_REFERENCE)
> {
> tree descriptor_data;
>
More information about the Fortran
mailing list