------- Comment #2 from paul dot richard dot thomas at cea dot fr  2006-10-02 
14:32 -------
(In reply to comment #1)
> The problem occurs on i386-*-freebsd

Noting that adding a dummy to the first of the subroutine declarations allows
the compiler to detect that there are two subroutines of the same name, we are
led by the error mesage to decl.c:636. The condition for detection of a
previously defined procedure is sym->formal [!= NULL].  Thus the case above
escapes. Patching this with:

Index: gcc/fortran/decl.c
===================================================================
*** gcc/fortran/decl.c  (révision 117367)
--- gcc/fortran/decl.c  (copie de travail)
*************** get_proc_name (const char *name, gfc_sym
*** 635,641 ****
         accessible names.  */
        if (sym->attr.flavor != 0
            && sym->attr.proc != 0
!           && sym->formal)
        gfc_error_now ("Procedure '%s' at %C is already defined at %L",
                       name, &sym->declared_at);

--- 635,642 ----
         accessible names.  */
        if (sym->attr.flavor != 0
            && sym->attr.proc != 0
!           && (sym->attr.subroutine || sym->attr.function)
!           && sym->attr.if_source != IFSRC_UNKNOWN)
        gfc_error_now ("Procedure '%s' at %C is already defined at %L",
                       name, &sym->declared_at);

seems to do the right thing.  The attributes subroutine and function are not of
themselves enough, as I discovered when I had to correct the original patch.
This condition was replaced with that on sym->formal and tested with
internal_references_2.f90. Adding the check that the symbol has an interface
source to the subroutine/function test accomplishes the same thing and scoops
up procedures without dummies.

It regtests OK on Cygwin_NT/PIV.

Paul


-- 


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

Reply via email to