------- Comment #4 from pault at gcc dot gnu dot org  2007-10-26 09:36 -------
This gives the correct behaviour:

Index: gcc/fortran/decl.c
===================================================================
*** gcc/fortran/decl.c  (révision 129434)
--- gcc/fortran/decl.c  (copie de travail)
*************** gfc_match_entry (void)
*** 4376,4382 ****
    if (state == COMP_SUBROUTINE)
      {
        /* An entry in a subroutine.  */
!       if (!add_global_entry (name, 1))
        return MATCH_ERROR;

        m = gfc_match_formal_arglist (entry, 0, 1);
--- 4376,4382 ----
    if (state == COMP_SUBROUTINE)
      {
        /* An entry in a subroutine.  */
!       if (!gfc_current_ns->parent && !add_global_entry (name, 1))
        return MATCH_ERROR;

        m = gfc_match_formal_arglist (entry, 0, 1);
*************** gfc_match_entry (void)
*** 4398,4404 ****
            ENTRY f() RESULT (r)
         can't be written as
            ENTRY f RESULT (r).  */
!       if (!add_global_entry (name, 0))
        return MATCH_ERROR;

        old_loc = gfc_current_locus;
--- 4398,4404 ----
            ENTRY f() RESULT (r)
         can't be written as
            ENTRY f RESULT (r).  */
!       if (!gfc_current_ns->parent && !add_global_entry (name, 0))
        return MATCH_ERROR;

        old_loc = gfc_current_locus;

such that 

MODULE ksbin1_aux_mod
 CONTAINS
  SUBROUTINE nxtstg()
    INTEGER :: i
    INTEGER :: setbd
    i = setbd()  ! available by host association.
    write(6,*) i
  END SUBROUTINE nxtstg
  FUNCTION binden()
    INTEGER :: binden
    INTEGER :: setbd
    binden = 0
  ENTRY setbd()
    setbd = 99
  END FUNCTION binden
END MODULE ksbin1_aux_mod

PROGRAM test
  USE ksbin1_aux_mod, only : nxtstg
  integer setbd ! setbd is external, since not use assoc.
  CALL nxtstg()
  print *, setbd ()
  call foo
contains
  subroutine foo
    USE ksbin1_aux_mod ! module setbd is available
    print *, setbd ()
  end subroutine
END PROGRAM test

INTEGER FUNCTION setbd()
  setbd=42
END FUNCTION setbd

gives

          99
          42
          99

Paul


-- 

pault at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pault at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-10-25 17:33:09         |2007-10-26 09:36:40
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33897

Reply via email to