[PATCH v3 2/5] fortran: Reverse actual vs dummy argument mapping

Mikael Morin mikael@gcc.gnu.org
Sun Nov 7 16:16:33 GMT 2021

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.

	* 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  | 31 +++++++++++++++++++++++++++--
 gcc/fortran/interface.c | 21 ++++++++++++++++++--
 gcc/fortran/intrinsic.c | 43 ++++++++++++++++++++++++++++++-----------
 3 files changed, 80 insertions(+), 15 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0002-fortran-Reverse-actual-vs-dummy-argument-mapping.patch
Type: text/x-patch
Size: 6379 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20211107/ba9946f5/attachment-0001.bin>

More information about the Gcc-patches mailing list