static bool
compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal,
- int ranks_must_agree, int is_elemental, locus *where)
+ int ranks_must_agree, int is_elemental,
+ bool in_statement_function, locus *where)
{
gfc_actual_arglist **new_arg, *a, *actual;
gfc_formal_arglist *f;
}
/* Check intent = OUT/INOUT for definable actual argument. */
- if ((f->sym->attr.intent == INTENT_OUT
- || f->sym->attr.intent == INTENT_INOUT))
+ if (!in_statement_function
+ && (f->sym->attr.intent == INTENT_OUT
+ || f->sym->attr.intent == INTENT_INOUT))
{
const char* context = (where
? _("actual argument to INTENT = OUT/INOUT")
"at %L", where);
return false;
}
- if (!f->sym->attr.optional)
+ if (!f->sym->attr.optional
+ || (in_statement_function && f->sym->attr.optional))
{
if (where)
gfc_error ("Missing actual argument for argument %qs at %L",
bool
gfc_procedure_use (gfc_symbol *sym, gfc_actual_arglist **ap, locus *where)
{
+ gfc_actual_arglist *a;
gfc_formal_arglist *dummy_args;
/* Warn about calls with an implicit interface. Special case
if (sym->attr.if_source == IFSRC_UNKNOWN)
{
- gfc_actual_arglist *a;
-
if (sym->attr.pointer)
{
gfc_error ("The pointer object %qs at %L must have an explicit "
dummy_args = gfc_sym_get_dummy_args (sym);
- if (!compare_actual_formal (ap, dummy_args, 0, sym->attr.elemental, where))
+ /* For a statement function, check that types and type parameters of actual
+ arguments and dummy arguments match. */
+ if (!compare_actual_formal (ap, dummy_args, 0, sym->attr.elemental,
+ sym->attr.proc == PROC_ST_FUNCTION, where))
return false;
-
+
if (!check_intents (dummy_args, *ap))
return false;
}
if (!compare_actual_formal (ap, comp->ts.interface->formal, 0,
- comp->attr.elemental, where))
+ comp->attr.elemental, false, where))
return;
check_intents (comp->ts.interface->formal, *ap);
dummy_args = gfc_sym_get_dummy_args (sym);
r = !sym->attr.elemental;
- if (compare_actual_formal (args, dummy_args, r, !r, NULL))
+ if (compare_actual_formal (args, dummy_args, r, !r, false, NULL))
{
check_intents (dummy_args, *args);
if (warn_aliasing)
--- /dev/null
+! { dg-do compile }
+! PR fortran/84276
+ subroutine stepns(hh, h, s, w)
+ real, intent(inout) :: h, hh, s
+ real, intent(out) :: w
+ real :: qofs
+ integer i
+ qofs(s) = s
+ w = qofs(hh + h)
+ i = 42
+ w = qofs(i) ! { dg-error "Type mismatch in argument" }
+ end subroutine stepns
+
+ subroutine step(hh, h, s, w)
+ real, intent(inout) :: h, hh, s
+ real, intent(out) :: w
+ real :: qofs
+ integer i
+ qofs(s, i) = i * s
+ i = 42
+ w = qofs(hh, i)
+!
+! The following line should cause an error, because keywords are not
+! allowed in a function with an implicit interface.
+!
+ w = qofs(i = i, s = hh)
+ end subroutine step
+! { dg-prune-output " Obsolescent feature" }