Bug 33945 - PROCEDURE in module somtimes wrongly rejected
Summary: PROCEDURE in module somtimes wrongly rejected
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2007-10-29 20:00 UTC by Tobias Burnus
Modified: 2007-11-08 15:39 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-11-02 15:31:25


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Burnus 2007-10-29 20:00:15 UTC
Compiling the following program gives the error:

  procedure(sub) :: x
                    1
Error: Duplicate PROCEDURE attribute specified at (1)

I think the program is valid and it is also accepted by NAG f95.


module m
  implicit none
  interface bar
    procedure x
  end interface bar
  procedure(sub) :: x
  interface
    subroutine sub()
    end subroutine sub
  end interface
end module m
Comment 1 Jerry DeLisle 2007-11-02 06:35:28 UTC
The statement:

   procedure x 

is an F2003 feature allowing the word 'module' preceding as optional.

If I use 'module procedure x' the test case compiles OK for me.  I think I may have fixed this with my pr33162 patch.  I seem to remember bumping into this
'Duplicate PROCEDURE attribute specified' error somewhere along the way. 
Comment 2 Tobias Burnus 2007-11-02 07:40:10 UTC
(In reply to comment #1)
> The statement:
>    procedure x 
> is an F2003 feature allowing the word 'module' preceding as optional.

Note: MODULE PROCEDURE and PROCEDURE mean different things.

"MODULE PROCEDURE" can only be a procedure which is a procedure from that module. "PROCEDURE" can be any procedure whose interface is explicitly known:
Module procedures, use-associated procedures, external procedures (via INTERFACE or PROCEDURE(...) statement).

> If I use 'module procedure x' the test case compiles OK for me.

I think this implies another bug as I believe there is not any module procedure in that module. Using "MODULE PROCEDURE" other compilers give also an error:

NAG f95:
Error: af.f90, line 11: Undefined module procedure X

g95:
Error: EXTERNAL-PROC procedure 'x' at (1) is already a MODULE-PROC procedure

> I think I may have fixed this with my pr33162 patch.  I seem to remember 
> bumping into this 'Duplicate PROCEDURE attribute specified' error somewhere 
> along the way.

I will try your pr33162 patch. (Might take a while since I have at the moment only a lousy internet connection.)
Comment 3 Jerry DeLisle 2007-11-02 13:29:03 UTC
Subject: Re:  PROCEDURE in module somtimes wrongly rejected

burnus at gcc dot gnu dot org wrote:
> ------- Comment #2 from burnus at gcc dot gnu dot org  2007-11-02 07:40 -------
> Note: MODULE PROCEDURE and PROCEDURE mean different things.
> 
> "MODULE PROCEDURE" can only be a procedure which is a procedure from that
> module. "PROCEDURE" can be any procedure whose interface is explicitly known:
> Module procedures, use-associated procedures, external procedures (via
> INTERFACE or PROCEDURE(...) statement).
>

Is that PROCEDURE(...) with or without the parenthesis?  We need to parse this 
correctly without a doubt or we have to search the module to tell the 
difference? (If the 'MODULE' key word is optional for "MODULE PROCEDURE".)
Comment 4 Tobias Burnus 2007-11-08 15:29:24 UTC
Both problems fixed on the trunk (4.3.0). Other branches are not affected as PROCEDURE is new.
Comment 5 Tobias Burnus 2007-11-08 15:39:03 UTC
The check-in was the following (note the wrong bug number).

Author: burnus
Date: Thu Nov  8 15:28:30 2007
New Revision: 130002

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130002
Log:
2007-11-08  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33917
        * interface.c (check_sym_interfaces): Disallow PROCEDURE-declared
        procedures for MODULE PROCEDURE.
        * decl.c (match_procedure_in_interface): Do not mark as procedure.

2007-11-08  Tobias Burnus  <burnus@net-b.de>

        PR fortran/33917
        * gfortran.dg/proc_decl_5.f90: New.
        * gfortran.dg/proc_decl_6.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/proc_decl_5.f90
    trunk/gcc/testsuite/gfortran.dg/proc_decl_6.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/interface.c
    trunk/gcc/testsuite/ChangeLog
Comment 6 patchapp@dberlin.org 2007-11-10 03:54:59 UTC
Subject: Bug number PR33945

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00416.html
Comment 7 patchapp@dberlin.org 2007-11-10 17:26:44 UTC
Subject: Bug number PR33945

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00416.html
Comment 8 patchapp@dberlin.org 2007-11-20 05:05:40 UTC
Subject: Bug number PR33945

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-11/msg00416.html