gcc/fortran/ChangeLog:
PR fortran/104572
* resolve.cc (gfc_resolve_finalizers): Argument of a FINAL subroutine
cannot be an alternate return.
gcc/testsuite/ChangeLog:
PR fortran/104572
* gfortran.dg/pr104572.f90: New test.
Co-authored-by: Steven G. Kargl <kargl@gcc.gnu.org>
}
arg = dummy_args->sym;
+ if (!arg)
+ {
+ gfc_error ("Argument of FINAL procedure at %L must be of type %qs",
+ &list->proc_sym->declared_at, derived->name);
+ goto error;
+ }
+
if (arg->as && arg->as->type == AS_ASSUMED_RANK
&& ((list != derived->f2k_derived->finalizers) || list->next))
{
--- /dev/null
+! { dg-do compile }
+! { dg-additional-options "-w" }
+! PR fortran/104572 - ICE in gfc_resolve_finalizers
+! Contributed by G. Steinmetz
+
+module m
+ type t
+ contains
+ final :: s
+ end type
+contains
+ subroutine s(*) ! { dg-error "Argument of FINAL procedure" }
+ end
+end