https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90166
--- Comment #4 from Steve Kargl <sgk at troutmask dot apl.washington.edu> --- On Fri, Apr 19, 2019 at 01:09:25AM +0000, sgk at troutmask dot apl.washington.edu wrote: > > This survives regression testing, but boy is it ugly. > > Index: decl.c > =================================================================== > --- decl.c (revision 270181) > +++ decl.c (working copy) > @@ -6103,6 +6103,19 @@ gfc_match_prefix (gfc_typespec *ts) > if (!gfc_notify_std (GFC_STD_F2008, "MODULE prefix at %C")) > goto error; > > + if (gfc_current_state () != COMP_MODULE > + && gfc_current_state () != COMP_SUBMODULE > + && gfc_current_state () != COMP_INTERFACE > + && gfc_current_state () != COMP_CONTAINS This is likely incorrect. A CONTAINS can appear in the program, a subroutine, or function. Need to check that the CONTAINS is with a module. That is, someone could do function foo contains module subroutine bar end subroutine bar end function foo