the same string length, i.e. both len=*, or both len=4.
Having both len=<variable> is also possible, but difficult to
check at compile time. */
+ else if (ts->type == BT_CHARACTER
+ && (el->sym->result->attr.allocatable
+ != ns->entries->sym->result->attr.allocatable))
+ {
+ 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;
+ }
else if (ts->type == BT_CHARACTER && ts->u.cl && fts->u.cl
&& (((ts->u.cl->length && !fts->u.cl->length)
||(!ts->u.cl->length && fts->u.cl->length))
--- /dev/null
+! { dg-do compile }
+! PR fortran/87737 - improve check on function entry characteristics
+
+function f() ! { dg-error "mismatched characteristics" }
+ character(:), allocatable :: f
+ character(1) :: g
+ f = 'f'
+ return
+entry g()
+ g = 'g'
+end
+
+function f2() ! { dg-error "mismatched characteristics" }
+ character(1) :: f2
+ character(1), allocatable :: g2
+ f2 = 'f'
+ return
+entry g2()
+ g2 = 'g'
+end