The attached patch fixes an ICE by reporting an error for the re-declaration of a subroutine by trying to include itself as an internal subprogram. Regression tested on x86_64-*-freebsd and i568-*-freebsd. OK to commit? 2018-03-17 Steven G. Kargl PR fortran/77414 * decl.c (get_proc_name): Check for a subroutine re-defined in the contain portion of a subroutine. Change language of existing error message to better describe the issue. While here fix whitespace issues. 2018-03-17 Steven G. Kargl PR fortran/77414 * gfortran.dg/pr77414.f90: New test. * gfortran.dg/internal_references_1.f90: Adjust error message. -- Steve