[PATCH 0/7] fortran: Ignore unused arguments for scalarisation [PR97896]

2021-08-03 Thread Mikael Morin via Fortran
Hello, I have had these patches fixing PR97896 almost ready for a while. Now is time to actually submit them, at last. The problematic case is intrinsic procedures where an argument is actually not used in the code generated (KIND argument of INDEX in the testcase), which confuses the scalari

[PATCH 2/7] fortran: Tiny sort_actual internal refactoring

2021-08-03 Thread Mikael Morin via Fortran
Preliminary refactoring to make further changes more obvious. No functional change. gcc/fortran/ * intrinsic.c (sort_actual): initialise variable and use it earlier. --- gcc/fortran/intrinsic.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/gcc/fortran/intrins

[PATCH 1/7] fortran: new abstract class gfc_dummy_arg

2021-08-03 Thread Mikael Morin via Fortran
Introduce a new abstract class gfc_dummy_arg that provides a common interface to both dummy arguments of user-defined procedures (which have type gfc_formal_arglist) and dummy arguments of intrinsic procedures (which have type gfc_intrinsic_arg). gcc/fortran/ * gfortran.h (gfc_dummy_arg):

[PATCH 3/7] fortran: Reverse actual vs dummy argument mapping

2021-08-03 Thread Mikael Morin via Fortran
There was originally no way from an actual argument to get to the corresponding dummy argument, even if the job of sorting and matching actual with dummy arguments was done. The closest was a field named actual in gfc_intrinsic_arg that was used as scratch data when sorting arguments of one specif

[PATCH 4/7] fortran: simplify elemental arguments walking

2021-08-03 Thread Mikael Morin via Fortran
This adds two methods to the abstract gfc_dummy_arg and makes usage of them to simplify a bit the walking of elemental procedure arguments for scalarization. As information about dummy arguments can be obtained from the actual argument through the just-introduced associated_dummy field, there is

[PATCH 5/7] fortran: Delete redundant missing_arg_type field

2021-08-03 Thread Mikael Morin via Fortran
Now that we can get information about an actual arg's associated dummy using the associated_dummy attribute, the field missing_arg_type contains redundant information. This removes it. gcc/fortran/ * gfortran.h (gfc_actual_arglist::missing_arg_type): Remove. * interface.c (gfc_com

[PATCH 6/7] Revert "Remove KIND argument from INDEX so it does not mess up scalarization."

2021-08-03 Thread Mikael Morin via Fortran
This reverts commit d09847357b965a2c2cda063827ce362d4c9c86f2 except for its testcase. gcc/fortran/ * intrinsic.c (add_sym_4ind): Remove. (add_functions): Use add_sym4 instead of add_sym4ind. Don’t special case the index intrinsic. * iresolve.c (gfc_resolve_index_fu

[PATCH 7/7] fortran: Ignore unused args in scalarization [PR97896]

2021-08-03 Thread Mikael Morin via Fortran
The KIND argument of the INDEX intrinsic is a compile time constant that is used at compile time only to resolve to a kind-specific library method. It is otherwise completely ignored at runtime, and there is no code generated for it as the library procedure has no kind argument. This confuses the

Re: [PATCH] PR fortran/100950 - ICE in output_constructor_regular_field, at varasm.c:5514

2021-08-03 Thread Harald Anlauf via Fortran
Here's now my third attempt to fix this PR, taking into account the comments by Tobias and Bernhard. > > On 10.06.21 20:52, Harald Anlauf via Fortran wrote: > > > +static bool > > > +substring_has_constant_len (gfc_expr *e) > > > +{ > > > + ptrdiff_t istart, iend; > > > + size_t length; > > > +