Bug 77414 - ICE in create_function_arglist, at fortran/trans-decl.c:2410
Summary: ICE in create_function_arglist, at fortran/trans-decl.c:2410
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 7.0
: P4 normal
Target Milestone: 7.4
Assignee: kargls
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2016-08-30 18:45 UTC by Gerhard Steinmetz
Modified: 2018-03-19 19:18 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2016-09-03 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerhard Steinmetz 2016-08-30 18:45:17 UTC
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
Comment 1 Gerhard Steinmetz 2016-08-30 18:46:50 UTC
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
Comment 2 Dominique d'Humieres 2016-09-03 13:40:10 UTC
Confirmed from 4.8 up to trunk (7.0).
Comment 3 Dominique d'Humieres 2016-11-09 22:49:24 UTC
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.
Comment 4 Dominique d'Humieres 2016-11-10 22:54:03 UTC
> 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).
Comment 5 Dominique d'Humieres 2016-12-07 12:26:12 UTC
> > 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.
Comment 6 kargls 2018-03-18 06:35:49 UTC
I have patch.
Comment 7 kargls 2018-03-18 17:52:29 UTC
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
Comment 8 kargls 2018-03-19 18:55:00 UTC
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
Comment 9 kargls 2018-03-19 19:18:32 UTC
Fixed on 7-branch and trunk.  Thanks for bug report.
Patch does not apply cleanly to 6-branch.