With invalid code, down to at least 4.8, related to pr44348 : $ cat z1.f90 subroutine s(x) character(*) :: x contains subroutine s(x) character(*) :: x end end $ gfortran-7-20160828 z1.f90 z1.f90:4:0: subroutine s(x) internal compiler error: in create_function_arglist, at fortran/trans-decl.c:2410 0x742cf1 create_function_arglist ../../gcc/fortran/trans-decl.c:2410 0x746bb9 gfc_create_function_decl(gfc_namespace*, bool) ../../gcc/fortran/trans-decl.c:2820 0x74f349 gfc_generate_contained_functions ../../gcc/fortran/trans-decl.c:5185 0x74f349 gfc_generate_function_code(gfc_namespace*) ../../gcc/fortran/trans-decl.c:6143 0x6db090 translate_all_program_units ../../gcc/fortran/parse.c:5910 0x6db090 gfc_parse_file() ../../gcc/fortran/parse.c:6116 0x71d3a2 gfc_be_parse_file ../../gcc/fortran/f95-lang.c:198
Backup tests, more variants : $ cat z2.f90 subroutine s(x) real :: x contains subroutine s(x) character(*) :: x end end $ cat z3.f90 subroutine s(x) real :: x contains subroutine s(x) character(:), allocatable :: x end end $ cat z4.f90 subroutine s(x) character(*) :: x contains subroutine s(x) character(:), allocatable :: x end end --- Generating backtrace from pr44348 : $ cat z7.f90 subroutine s(x) character(*) :: x contains subroutine s(x) real :: x end end $ cat z8.f90 subroutine s(x) character(*) :: x contains subroutine s(x) real :: x(*) end end $ cat z9.f90 subroutine s(x) character(*) :: x contains subroutine s(x) character :: x(*) end end
Confirmed from 4.8 up to trunk (7.0).
The tests z7.f90, z8.f90, and z9.f90 compiles without error at revision r242002 although I think they are invalid. They give an ICE with r241962.
> The tests z7.f90, z8.f90, and z9.f90 compiles without error > at revision r242002 although I think they are invalid. > They give an ICE with r241962. This is due to r241972 (pr77596).
> > The tests z7.f90, z8.f90, and z9.f90 compiles without error > > at revision r242002 although I think they are invalid. > > They give an ICE with r241962. > > This is due to r241972 (pr77596). This is wrong, it is due to patches for pr44265: see https://gcc.gnu.org/ml/fortran/2016-12/msg00055.html.
I have patch.
Author: kargl Date: Sun Mar 18 17:51:57 2018 New Revision: 258633 URL: https://gcc.gnu.org/viewcvs?rev=258633&root=gcc&view=rev Log: 2018-03-18 Steven G. Kargl <kargl@gcc.gnu.org> 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-18 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/77414 * gfortran.dg/pr77414.f90: New test. * gfortran.dg/internal_references_1.f90: Adjust error message. Added: trunk/gcc/testsuite/gfortran.dg/pr77414.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/decl.c trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/internal_references_1.f90
Author: kargl Date: Mon Mar 19 18:54:29 2018 New Revision: 258654 URL: https://gcc.gnu.org/viewcvs?rev=258654&root=gcc&view=rev Log: 2018-03-19 Steven G. Kargl <kargl@gcc.gnu.org> 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-19 Steven G. Kargl <kargl@gcc.gnu.org> PR fortran/77414 * gfortran.dg/pr77414.f90: New test. * gfortran.dg/internal_references_1.f90: Adjust error message. Added: branches/gcc-7-branch/gcc/testsuite/gfortran.dg/pr77414.f90 Modified: branches/gcc-7-branch/gcc/fortran/ChangeLog branches/gcc-7-branch/gcc/fortran/decl.c branches/gcc-7-branch/gcc/testsuite/ChangeLog branches/gcc-7-branch/gcc/testsuite/gfortran.dg/internal_references_1.f90
Fixed on 7-branch and trunk. Thanks for bug report. Patch does not apply cleanly to 6-branch.