GCC Bugzilla has been upgraded from version 4.4.9 to 5.0rc3. If you see any problem, please report it to bug 64968.

Bug 49265

Summary: Double colon in procedure-stmt (generic interface)
Product: gcc Reporter: Erik Toussaint <eh.toussaint>
Component: fortranAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: minor CC: burnus, janus, kargl
Priority: P3 Keywords: rejects-valid
Version: 4.7.0   
Target Milestone: 4.6.1   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2011-06-02 00:26:32

Description Erik Toussaint 2011-06-01 23:28:23 UTC
In Fortran 2008 the (module) procedure statement in a generic
interface can contain a double colon, according to R1206:

R1206  procedure-stmt   is   [ MODULE ] PROCEDURE [ :: ] procedure-name-list

When I try to compile the following module with gfortran 4.7-20110423
I get an error.

module m1
  implicit none
  interface foo
     module procedure :: bar
  end interface
contains
  subroutine bar
  end subroutine
end module

$ gfortran -c -std=f2008 m1.f90
m1.f90:4.23:

     module procedure :: bar
                      1
Error: Syntax error in MODULE PROCEDURE statement at (1)

(The '1' indicates the double colon as the location of the error.)

If I remove the double colon the file compiles without error - which is expected, as the optional double colon didn't appear in the rule in previous versions of the standard.

$ gcc -v
Using built-in specs.
COLLECT_GCC=d:\Programs\MinGW\gcc47\bin\gcc.exe
COLLECT_LTO_WRAPPER=d:/programs/mingw/gcc47/bin/../libexec/gcc/i686-pc-mingw32/4
.7.0/lto-wrapper.exe
Target: i686-pc-mingw32
Configured with: ../src/configure --prefix=/mingw --with-gmp=/mingw --with-mpfr=
/mingw --with-mpc=/mingw --disable-nls --enable-languages=c,c++,fortran --enable
-libgomp --disable-win32-registry
Thread model: win32
gcc version 4.7.0 20110423 (experimental) (GCC)
Comment 1 kargl 2011-06-02 00:26:32 UTC
I have a patch that is regression testing.


F95 has

R1206 module-procedure-stmt is MODULE PROCEDURE procedure-name-list

F2003 has

R1206 procedure-stmt is [ MODULE ] PROCEDURE procedure-name-list

F2008 has

R1206 procedure-stmt is [ MODULE ] PROCEDURE [ :: ] procedure-name-list
Comment 2 kargl 2011-06-02 17:39:14 UTC
Author: kargl
Date: Thu Jun  2 17:39:11 2011
New Revision: 174569

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174569
Log:
2011-06-02  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/49265
	* decl.c (gfc_match_modproc):  Allow for a double colon in a module
	procedure statement.
	* parse.c ( decode_statement): Deal with whitespace around :: in
	gfc_match_modproc.
 
2011-06-02  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/49265
	* gfortran.dg/module_procedure_double_colon_1.f90: New test.
	* gfortran.dg/module_procedure_double_colon_2.f90: New test.


Added:
    trunk/gcc/testsuite/gfortran.dg/module_procedure_double_colon_1.f90
    trunk/gcc/testsuite/gfortran.dg/module_procedure_double_colon_2.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/parse.c
    trunk/gcc/testsuite/ChangeLog
Comment 3 kargl 2011-06-02 19:53:05 UTC
Author: kargl
Date: Thu Jun  2 19:53:02 2011
New Revision: 174576

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=174576
Log:
2011-06-02  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/49265
	* decl.c (gfc_match_modproc):  Allow for a double colon in a module
	procedure statement.
	* parse.c ( decode_statement): Deal with whitespace around :: in
	gfc_match_modproc.
 
2011-06-02  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/49265
	* gfortran.dg/module_procedure_double_colon_1.f90: New test.
	* gfortran.dg/module_procedure_double_colon_2.f90: New test.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/module_procedure_double_colon_1.f90
    branches/gcc-4_6-branch/gcc/testsuite/gfortran.dg/module_procedure_double_colon_2.f90
Modified:
    branches/gcc-4_6-branch/gcc/fortran/ChangeLog
    branches/gcc-4_6-branch/gcc/fortran/decl.c
    branches/gcc-4_6-branch/gcc/fortran/parse.c
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
Comment 4 kargl 2011-06-02 19:55:05 UTC
Fixed on trunk and 4.6 branch.
Thanks for the bug report.
Comment 5 Erik Toussaint 2012-07-13 22:30:24 UTC
Sorry to reopen this after more than a year.
I think the following syntax, without the 'module' prefix, is also supposed to be ok, but it's currently not accepted (gfortran 4.7.0), with the same error message as in the original report.

        procedure :: bar
                 1
Error: Syntax error in PROCEDURE statement at (1)
Comment 6 Tobias Burnus 2012-07-14 11:21:27 UTC
Confirmed, one just needs to do the same as Steve did for decl.c's gfc_match_modproc (cf. comment 2) also in match_procedure_in_interface.
Comment 7 Tobias Burnus 2012-07-17 08:59:22 UTC
Author: burnus
Date: Tue Jul 17 08:59:18 2012
New Revision: 189562

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=189562
Log:
2012-07-17  Tobias Burnus  <burnus@net-b.de>
            Steven G. Kargl  <kargl@gcc.gnu.org>

        PR fortran/49265
        * decl.c (match_procedure_in_interface): Support "::" for
        Fortran 2008 and later.

2012-07-17  Tobias Burnus  <burnus@net-b.de>

        PR fortran/49265
        * gfortran.dg/module_procedure_double_colon_3.f90: New.
        * gfortran.dg/module_procedure_double_colon_4.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/module_procedure_double_colon_3.f90
    trunk/gcc/testsuite/gfortran.dg/module_procedure_double_colon_4.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/testsuite/ChangeLog
Comment 8 Tobias Burnus 2012-07-17 09:00:39 UTC
FIXED for the trunk (GCC 4.8).

Sorry for only partially fixing it before.