goto cleanup;
}
+ if (e->expr_type == EXPR_VARIABLE
+ && e->ts.type == BT_PROCEDURE
+ && no_formal_args
+ && sym->attr.flavor == FL_PROCEDURE
+ && sym->attr.if_source == IFSRC_UNKNOWN
+ && !sym->attr.external
+ && !sym->attr.intrinsic
+ && !sym->attr.artificial
+ && !sym->ts.interface)
+ {
+ /* Emit a warning for -std=legacy and an error otherwise. */
+ if (gfc_option.warn_std == 0)
+ gfc_warning (0, "Procedure %qs at %L used as actual argument but "
+ "does neither have an explicit interface nor the "
+ "EXTERNAL attribute", sym->name, &e->where);
+ else
+ {
+ gfc_error ("Procedure %qs at %L used as actual argument but "
+ "does neither have an explicit interface nor the "
+ "EXTERNAL attribute", sym->name, &e->where);
+ goto cleanup;
+ }
+ }
+
first_actual_arg = false;
}
--- /dev/null
+! { dg-do compile }
+! PR fortran/50377
+!
+! Reject procedures passed as actual argument if there is no explicit
+! interface and they are not declared EXTERNAL
+!
+! Contributed by Vittorio Zecca
+
+! external sub ! Required for valid code
+! external fun ! Required for valid code
+ call sub(sub) ! { dg-error "used as actual argument" }
+ z = fun(fun) ! { dg-error "used as actual argument" }
+ end
+
+ subroutine sub(y)
+ external y
+ end
+
+ real function fun(z)
+ external z
+ f = 1.
+ end
! { dg-do compile }
! { dg-options "-O3 -std=legacy" }
+ SUBROUTINE PR41011 (DCDX)
+ DIMENSION DCDX(*)
CALL UVSET(NX,NY,NZ,HVAR,ZET,NP,DZ,DKM,UM,VM,UG,VG,TM,DCDX, ! { dg-warning "Rank mismatch|Invalid procedure argument" }
*ITY,ISH,NSMT,F)
CALL DCTDX(NX,NY,NX1,NFILT,C(MLAG),DCDX(MLAG),HELP,HELPA,