aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/gfortran.h
diff options
context:
space:
mode:
authorMikael Morin <mikael@gcc.gnu.org>2021-11-07 14:39:59 +0100
committerMikael Morin <mikael@gcc.gnu.org>2021-11-16 19:07:50 +0100
commit5888512f24121032a438e3aaf10dc93550dc2819 (patch)
tree08c69e079127c0ca933218c2bd9df5b92cfc2e48 /gcc/fortran/gfortran.h
parentc31733c3bf57d4cfc31e8d7a95b0ba2cd41e6ea3 (diff)
downloadgcc-5888512f24121032a438e3aaf10dc93550dc2819.zip
gcc-5888512f24121032a438e3aaf10dc93550dc2819.tar.gz
gcc-5888512f24121032a438e3aaf10dc93550dc2819.tar.bz2
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.
Diffstat (limited to 'gcc/fortran/gfortran.h')
-rw-r--r--gcc/fortran/gfortran.h31
1 files changed, 29 insertions, 2 deletions
diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h
index 1ad2f0d..86c096a9 100644
--- a/gcc/fortran/gfortran.h
+++ b/gcc/fortran/gfortran.h
@@ -1199,6 +1199,9 @@ gfc_formal_arglist;
#define gfc_get_formal_arglist() XCNEW (gfc_formal_arglist)
+struct gfc_dummy_arg;
+
+
/* The gfc_actual_arglist structure is for actual arguments and
for type parameter specification lists. */
typedef struct gfc_actual_arglist
@@ -1215,6 +1218,11 @@ typedef struct gfc_actual_arglist
gfc_param_spec_type spec_type;
struct gfc_expr *expr;
+
+ /* The dummy arg this actual arg is associated with, if the interface
+ is explicit. NULL otherwise. */
+ gfc_dummy_arg *associated_dummy;
+
struct gfc_actual_arglist *next;
}
gfc_actual_arglist;
@@ -2299,14 +2307,33 @@ typedef struct gfc_intrinsic_arg
gfc_typespec ts;
unsigned optional:1, value:1;
ENUM_BITFIELD (sym_intent) intent:2;
- gfc_actual_arglist *actual;
struct gfc_intrinsic_arg *next;
-
}
gfc_intrinsic_arg;
+typedef enum {
+ GFC_UNDEFINED_DUMMY_ARG = 0,
+ GFC_INTRINSIC_DUMMY_ARG,
+ GFC_NON_INTRINSIC_DUMMY_ARG
+}
+gfc_dummy_arg_intrinsicness;
+
+/* dummy arg of either an intrinsic or a user-defined procedure. */
+struct gfc_dummy_arg
+{
+ gfc_dummy_arg_intrinsicness intrinsicness;
+
+ union {
+ gfc_intrinsic_arg *intrinsic;
+ gfc_formal_arglist *non_intrinsic;
+ } u;
+};
+
+#define gfc_get_dummy_arg() XCNEW (gfc_dummy_arg)
+
+
/* Specifies the various kinds of check functions used to verify the
argument lists of intrinsic functions. fX with X an integer refer
to check functions of intrinsics with X arguments. f1m is used for