Bug 68319 - ICE on using interface with included entry
Summary: ICE on using interface with included entry
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 5.2.1
: P3 normal
Target Milestone: 5.3
Assignee: kargls
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-11-12 17:56 UTC by Gerhard Steinmetz
Modified: 2015-11-13 21:29 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-11-13 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gerhard Steinmetz 2015-11-12 17:56:48 UTC
An interface declaration with an included entry :

$ cat z1.f90
module m
   interface
      subroutine s
      entry e
      end
   end interface
contains
   subroutine g
      call s
   end
end


$ gfortran -g -O0 -Wall -fcheck=all -c z1.f90
z1.f90:9:0:

       call s
 1
internal compiler error: in gfc_get_extern_function_decl, at fortran/trans-decl.c:1776
Comment 1 Gerhard Steinmetz 2015-11-12 17:57:36 UTC
Same issue with interface of a function.


Compiles if interface is effectivly not used :

$ cat z1x.f90
module m
   interface
      subroutine s
      entry e
      end
   end interface
contains
   subroutine g
   end
end

$ gfortran -g -O0 -Wall -fcheck=all -c z1x.f90
Comment 2 kargls 2015-11-13 00:42:16 UTC
It seems that gfortran is missing a check for ENTRY.  F2008 has

C1206 (R1205) An interface-body shall not contain a data-stmt, format-stmt, entry-stmt, or stmt-function-stmt.
Comment 3 Steve Kargl 2015-11-13 15:12:36 UTC
On Fri, Nov 13, 2015 at 12:42:16AM +0000, kargl at gcc dot gnu.org wrote:
> --- Comment #2 from kargl at gcc dot gnu.org ---
> It seems that gfortran is missing a check for ENTRY.  F2008 has
> 
> C1206 (R1205) An interface-body shall not contain a data-stmt, format-stmt,
> entry-stmt, or stmt-function-stmt.
> 

In fact, gfortran is not issues an error for data-stmt, format-stmt,
or stmt-function-stmt.
Comment 4 Dominique d'Humieres 2015-11-13 15:42:25 UTC
> In fact, gfortran is not issues an error for data-stmt, format-stmt,
> or stmt-function-stmt.

Confirmed: the following test compiles

module m
   interface
      subroutine s
      entry e
        integer :: x
        data x /1/
        f(x) = x*x
10      format (a)
      end
   end interface
contains
   subroutine g
   end
end
Comment 5 kargls 2015-11-13 16:07:44 UTC
Working on this.
Comment 6 Steve Kargl 2015-11-13 16:08:05 UTC
On Fri, Nov 13, 2015 at 12:42:16AM +0000, kargl at gcc dot gnu.org wrote:
>
> It seems that gfortran is missing a check for ENTRY.  F2008 has
> 
> C1206 (R1205) An interface-body shall not contain a data-stmt, format-stmt,
> entry-stmt, or stmt-function-stmt.
> 

I have a patch for stmt-function-stmt and entry.
data-stmt and format-stmt will follow shortly.
Comment 7 Steve Kargl 2015-11-13 16:27:27 UTC
On Fri, Nov 13, 2015 at 04:08:05PM +0000, sgk at troutmask dot apl.washington.edu wrote:
> --- Comment #6 from Steve Kargl <sgk at troutmask dot apl.washington.edu> ---
> On Fri, Nov 13, 2015 at 12:42:16AM +0000, kargl at gcc dot gnu.org wrote:
> >
> > It seems that gfortran is missing a check for ENTRY.  F2008 has
> > 
> > C1206 (R1205) An interface-body shall not contain a data-stmt, format-stmt,
> > entry-stmt, or stmt-function-stmt.
> > 
> 
> I have a patch for stmt-function-stmt and entry.
> data-stmt and format-stmt will follow shortly.
> 

I now have data-stmt and format-stmt covered.  Patch to be submitted
later today.
Comment 8 kargls 2015-11-13 21:12:14 UTC
Author: kargl
Date: Fri Nov 13 21:11:42 2015
New Revision: 230351

URL: https://gcc.gnu.org/viewcvs?rev=230351&root=gcc&view=rev
Log:
2015-11-13  Steven G. Kargl  <kargl@gccc.gnu.org>

	PR fortran/68319
	* decl.c (gfc_match_data, gfc_match_entry): Enforce F2008:C1206.
	* io.c (gfc_match_format): Ditto.
	* match.c (gfc_match_st_function): Ditto.

2015-11-13  Steven G. Kargl  <kargl@gccc.gnu.org>

	PR fortran/68319
	* gfortran.dg/pr68319.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/pr68319.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/io.c
    trunk/gcc/fortran/match.c
    trunk/gcc/testsuite/ChangeLog
Comment 9 kargls 2015-11-13 21:28:42 UTC
Author: kargl
Date: Fri Nov 13 21:28:10 2015
New Revision: 230352

URL: https://gcc.gnu.org/viewcvs?rev=230352&root=gcc&view=rev
Log:
2015-11-13  Steven G. Kargl  <kargl@gccc.gnu.org>

	PR fortran/68319
	* decl.c (gfc_match_data, gfc_match_entry): Enforce F2008:C1206.
	* io.c (gfc_match_format): Ditto.
	* match.c (gfc_match_st_function): Ditto.

2015-11-13  Steven G. Kargl  <kargl@gccc.gnu.org>

	PR fortran/68319
	* gfortran.dg/pr68319.f90: New test.

Added:
    branches/gcc-5-branch/gcc/testsuite/gfortran.dg/pr68319.f90
Modified:
    branches/gcc-5-branch/gcc/fortran/ChangeLog
    branches/gcc-5-branch/gcc/fortran/decl.c
    branches/gcc-5-branch/gcc/fortran/io.c
    branches/gcc-5-branch/gcc/fortran/match.c
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
Comment 10 kargls 2015-11-13 21:29:28 UTC
Fixed on trunk and 5-branch.  Thanks for the bug report.