+2014-06-12 Tobias Burnus <burnus@net-b.de>
+
+ * gfortran.h (gfc_copy_formal_args_intr): Update prototype.
+ * symbol.c (gfc_copy_formal_args_intr): Handle the case
+ that absent optional arguments should be ignored.
+ * trans-intrinsic.c (gfc_get_symbol_for_expr): Ditto.
+ (gfc_conv_intrinsic_funcall,
+ conv_generic_with_optional_char_arg): Update call.
+ * resolve.c (gfc_resolve_intrinsic): Ditto.
+
2014-06-10 Dominique d'Humieres <dominiq@lps.ens.fr>
Mikael Morin <mikael@gcc.gnu.org>
bool gfc_type_is_extension_of (gfc_symbol *, gfc_symbol *);
bool gfc_type_compatible (gfc_typespec *, gfc_typespec *);
-void gfc_copy_formal_args_intr (gfc_symbol *, gfc_intrinsic_sym *);
+void gfc_copy_formal_args_intr (gfc_symbol *, gfc_intrinsic_sym *,
+ gfc_actual_arglist *);
void gfc_free_finalizer (gfc_finalizer *el); /* Needed in resolve.c, too */
return false;
}
- gfc_copy_formal_args_intr (sym, isym);
+ gfc_copy_formal_args_intr (sym, isym, NULL);
sym->attr.pure = isym->pure;
sym->attr.elemental = isym->elemental;
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;
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));
has the generic name. */
static gfc_symbol *
-gfc_get_symbol_for_expr (gfc_expr * expr)
+gfc_get_symbol_for_expr (gfc_expr * expr, bool ignore_optional)
{
gfc_symbol *sym;
sym->as->rank = expr->rank;
}
- gfc_copy_formal_args_intr (sym, expr->value.function.isym);
+ gfc_copy_formal_args_intr (sym, expr->value.function.isym,
+ ignore_optional ? expr->value.function.actual
+ : NULL);
return sym;
}
else
gcc_assert (expr->rank == 0);
- sym = gfc_get_symbol_for_expr (expr);
+ sym = gfc_get_symbol_for_expr (expr, se->ignore_optional);
/* Calls to libgfortran_matmul need to be appended special arguments,
to be able to call the BLAS ?gemm functions if required and possible. */
}
/* Build the call itself. */
- sym = gfc_get_symbol_for_expr (expr);
+ gcc_assert (!se->ignore_optional);
+ sym = gfc_get_symbol_for_expr (expr, false);
gfc_conv_procedure_call (se, sym, expr->value.function.actual, expr,
append_args);
gfc_free_symbol (sym);