]> git.ipfire.org Git - thirdparty/gcc.git/commit - gcc/fortran/interface.cc
fortran: Reverse actual vs dummy argument mapping
authorMikael Morin <mikael@gcc.gnu.org>
Sun, 7 Nov 2021 13:39:59 +0000 (14:39 +0100)
committerMikael Morin <mikael@gcc.gnu.org>
Tue, 16 Nov 2021 18:07:50 +0000 (19:07 +0100)
commit5888512f24121032a438e3aaf10dc93550dc2819
tree08c69e079127c0ca933218c2bd9df5b92cfc2e48
parentc31733c3bf57d4cfc31e8d7a95b0ba2cd41e6ea3
fortran: Reverse actual vs dummy argument mapping

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 specific call.
However that value was overwritten later on as arguments of another
call to the same procedure were sorted and matched.

This change removes that field from gfc_intrinsic_arg and adds instead
a new field associated_dummy in gfc_actual_arglist.

The new field has as type a new wrapper struct 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).

As the removed field was used in the code sorting and matching arguments,
that code has to be updated.  Two local vectors with matching indices
are introduced for respectively dummy and actual arguments, and the
loops are modified to use indices and update those argument vectors.

gcc/fortran/ChangeLog:
* gfortran.h (gfc_dummy_arg_kind, gfc_dummy_arg): New.
(gfc_actual_arglist): New field associated_dummy.
(gfc_intrinsic_arg): Remove field actual.
* interface.c (get_nonintrinsic_dummy_arg): New.
(gfc_compare_actual): Initialize associated_dummy.
* intrinsic.c (get_intrinsic_dummy_arg): New.
(sort_actual):  Add argument vectors.
Use loops with indices on argument vectors.
Initialize associated_dummy.
gcc/fortran/gfortran.h
gcc/fortran/interface.c
gcc/fortran/intrinsic.c