diff options
Diffstat (limited to 'gcc/fortran/symbol.c')
-rw-r--r-- | gcc/fortran/symbol.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index a0995b5..922b421 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -4042,16 +4042,21 @@ add_proc_interface (gfc_symbol *sym, ifsrc source, gfc_formal_arglist *formal) each arg is set according to the existing ones. This function is used when creating procedure declaration variables from a procedure declaration statement (see match_proc_decl()) to create the formal - args based on the args of a given named interface. */ + args based on the args of a given named interface. + + When an actual argument list is provided, skip the absent arguments. + To be used together with gfc_se->ignore_optional. */ void -gfc_copy_formal_args_intr (gfc_symbol *dest, gfc_intrinsic_sym *src) +gfc_copy_formal_args_intr (gfc_symbol *dest, gfc_intrinsic_sym *src, + gfc_actual_arglist *actual) { gfc_formal_arglist *head = NULL; gfc_formal_arglist *tail = NULL; gfc_formal_arglist *formal_arg = NULL; gfc_intrinsic_arg *curr_arg = NULL; gfc_formal_arglist *formal_prev = NULL; + gfc_actual_arglist *act_arg = actual; /* Save current namespace so we can change it for formal args. */ gfc_namespace *parent_ns = gfc_current_ns; @@ -4062,6 +4067,17 @@ gfc_copy_formal_args_intr (gfc_symbol *dest, gfc_intrinsic_sym *src) for (curr_arg = src->formal; curr_arg; curr_arg = curr_arg->next) { + /* Skip absent arguments. */ + if (actual) + { + gcc_assert (act_arg != NULL); + if (act_arg->expr == NULL) + { + act_arg = act_arg->next; + continue; + } + act_arg = act_arg->next; + } formal_arg = gfc_get_formal_arglist (); gfc_get_symbol (curr_arg->name, gfc_current_ns, &(formal_arg->sym)); |