https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101350
--- Comment #2 from kargl at gcc dot gnu.org --- (In reply to kargl from comment #1) > diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c > index 45c3ad387ac..897cfde3ed3 100644 > --- a/gcc/fortran/resolve.c > +++ b/gcc/fortran/resolve.c > @@ -15307,6 +15308,15 @@ resolve_symbol (gfc_symbol *sym) > return; > sym->resolve_symbol_called = 1; > > + /* Symbol cannot have an external attribute and be a contained procedure. > */ > + if (sym->attr.external && sym->attr.contained) > + { > + gfc_error ("Contained procedure %qs at %L conflicts with " > + "a previously declared EXTERNAL procedure", > + sym->name, &sym->declared_at); > + return; > + } > + > /* No symbol will ever have union type; only components can be unions. > Union type declaration symbols have type BT_UNKNOWN but flavor FL_UNION > (just like derived type declaration symbols have flavor FL_DERIVED). */ This patch works to fix the reported problem. It, however, causes a number regressions, which can be traced to confusing and conflicting settings of attributes. In particular, attr.external=1 is often set when attr.proc=PROC_MODULE or attr.module_procedure=1 occur. This should not happen as an external procedure can never be a module procedure.