User account creation filtered due to spam.

Bug 33917 - Rejects valid PROCEDURE declarations
Summary: Rejects valid PROCEDURE declarations
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Tobias Burnus
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2007-10-26 21:55 UTC by Francois-Xavier Coudert
Modified: 2007-11-15 15:18 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-10-27 15:30:19


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Francois-Xavier Coudert 2007-10-26 21:55:33 UTC
This one is a heisenbug, which showed up in the testsuite while testing a patch but is also present on trunk:

$ cat proc_decl_2.f90 
program s
  implicit none
  procedure() :: q2
  procedure() :: q3
  procedure() :: q5
  procedure(sub) :: p4
  procedure(p4) :: p6
contains
  subroutine sub
  end subroutine
end program s
$ gfortran proc_decl_2.f90
proc_decl_2.f90:7.21:

  procedure(p4) :: p6
                    1
Error: Interface 'p4' of procedure 'p6' at (1) must be explicit
Comment 1 Tobias Burnus 2007-10-26 21:59:55 UTC
As depending which line is commented out or not, the bug disappears or appears, my educated guess would be that one does not properly walk a tree and thus not all leafs are found.
Comment 2 Tobias Burnus 2007-10-26 23:14:23 UTC
  procedure(sub) :: p4
  procedure(p4) :: p6
The problem is that first sub needs to be resolved for p4 and then p4 before p6.

The problem is that "procedure(p4) :: p6" is checked before "procedure(sub) :: p4" and that thus for "p6" sym->interface->attr.if_source == IFSRC_UNKNOWN instead of IFSRC_DECL.

This seems to be a tree-walking problem. The solution is to make sure the interfaces are resolved first such that the following holds true:

      /* Get the attributes from the interface (now resolved).  */
Comment 3 Tobias Burnus 2007-10-27 15:30:18 UTC
Mine - I have patch.
Comment 4 Tobias Burnus 2007-10-28 19:57:06 UTC
See also:
http://groups.google.com/group/comp.lang.fortran/browse_thread/thread/2eea7b997482aa5e/

The answers decides whether
  http://gcc.gnu.org/ml/fortran/2007-10/msg00362.html
or
  http://gcc.gnu.org/ml/fortran/2007-10/msg00371.html
is the correct approach.

Additionally, we probably need to fix gfortran for the second example.

(The third question there is related to PR 33162.)
Comment 5 Tobias Burnus 2007-10-29 20:04:08 UTC
This gets difficult.

Using
  procedure(p4) :: p6
  procedure(sub) :: p4
is invalid per
"C1212 (R1215) [...] If name is declared by a procedure-declaration-stmt it shall be previously declared."
("name" = interface-name)

However, depending how the tree is parsed, it is rejected or not (rather independent of my patch).

Using Janus' patch, it is always accepted.
Comment 6 patchapp@dberlin.org 2007-10-30 03:45:37 UTC
Subject: Bug number PR 33917

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-10/msg01622.html
Comment 7 Tobias Burnus 2007-11-08 15:28:43 UTC
Subject: Bug 33917

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 8 Tobias Burnus 2007-11-08 15:36:38 UTC
Sorry, the check in was for PR 33917.
Comment 9 patchapp@dberlin.org 2007-11-15 12:35:43 UTC
Subject: Bug number PR33917

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/msg00842.html
Comment 10 Tobias Burnus 2007-11-15 15:12:14 UTC
Subject: Bug 33917

Author: burnus
Date: Thu Nov 15 15:12:03 2007
New Revision: 130202

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

        PR fortran/33917
        * decl.c (match_procedure_decl): Pre-resolve interface.
        * resolve.c (resolve_symbol): Reject interfaces later
        declared in procedure statements.

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

        PR fortran/33917
        * gfortran.dg/proc_decl_11.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/proc_decl_11.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/decl.c
    trunk/gcc/fortran/resolve.c
    trunk/gcc/testsuite/ChangeLog

Comment 11 Tobias Burnus 2007-11-15 15:18:37 UTC
FIXED on the trunk (4.3.0) [is not part of any branch].