===================================================================
*************** resolve_equivalence (gfc_equiv *eq)
static bool
flag_fn_result_spec (gfc_expr *expr,
! gfc_symbol *sym ATTRIBUTE_UNUSED,
int *f ATTRIBUTE_UNUSED)
{
gfc_namespace *ns;
static bool
flag_fn_result_spec (gfc_expr *expr,
! gfc_symbol *sym,
int *f ATTRIBUTE_UNUSED)
{
gfc_namespace *ns;
*************** flag_fn_result_spec (gfc_expr *expr,
if (!ns->parent)
break;
+ if (sym == s)
+ {
+ gfc_error ("Self reference in character length expression "
+ "for %qs at %L", sym->name, &expr->where);
+ return true;
+ }
+
if (!s->fn_result_spec
&& s->attr.flavor == FL_PARAMETER)
{
*************** resolve_fntype (gfc_namespace *ns)
}
if (sym->ts.type == BT_CHARACTER)
! gfc_traverse_expr (sym->ts.u.cl->length, NULL, flag_fn_result_spec, 0);
}
}
if (sym->ts.type == BT_CHARACTER)
! gfc_traverse_expr (sym->ts.u.cl->length, sym, flag_fn_result_spec, 0);
}
===================================================================
***************
+ ! { dg-do compile }
+ !
+ ! Tests the fix for PR80657.
+ !
+ ! Contributed by Vittorio Zecca <zeccav@gmail.com>
+ !
+ function f(x)
+ implicit character(len(f)) (x) ! { dg-error "Self reference in character length" }
+ character(len(x)) f
+ end