Fortran - fix ICE during error recovery checking entry characteristics

gcc/fortran/ChangeLog:

	PR fortran/102311
	* resolve.c (resolve_entries): Attempt to recover cleanly after
	rejecting mismatched function entries.

gcc/testsuite/ChangeLog:

	PR fortran/102311
	* gfortran.dg/entry_25.f90: New test.
This commit is contained in:
Harald Anlauf 2021-09-14 20:23:27 +02:00
parent c89d805397
commit b305ec979d
2 changed files with 16 additions and 1 deletions

View File

@ -811,7 +811,7 @@ resolve_entries (gfc_namespace *ns)
gfc_error ("Function %s at %L has entry %s with mismatched "
"characteristics", ns->entries->sym->name,
&ns->entries->sym->declared_at, el->sym->name);
return;
goto cleanup;
}
else if (ts->type == BT_CHARACTER && ts->u.cl && fts->u.cl
&& (((ts->u.cl->length && !fts->u.cl->length)
@ -917,6 +917,8 @@ resolve_entries (gfc_namespace *ns)
}
}
}
cleanup:
proc->attr.access = ACCESS_PRIVATE;
proc->attr.entry_master = 1;

View File

@ -0,0 +1,13 @@
! { dg-do compile }
! PR fortran/102311 - ICE during error recovery checking entry characteristics
module m
contains
function f() ! { dg-error "mismatched characteristics" }
character(:), allocatable :: f
character(1) :: g
f = 'f'
entry g()
g = 'g'
end
end