[gfortran] Patch for pr20363

Erik Edelmann eedelman@acclab.helsinki.fi
Thu Jul 7 23:47:00 GMT 2005


The attached patch fixes pr20363.  The problem was the function
find_special in decl.c.  When in an INTERFACE, we first checked
if the name was the name of the interface, and only then, if it
wasn't, we looked in the current name space.  With this patch, we
do it the other way around.

Bubblestrapped & reg.tested on Linux-x86, on mainline and 4.0.
Please commit if OK.


        Erik
 
 

Changelog entry for patch:

2005-07-08 Erik Edelmann <erik.edelmann@iki.fi>

        PR fortran/20363 
        * decl.c (find_special): Check current name space first.



Changelog entry for test case:

2005-07-08 Erik Edelmann <erik.edelmann@iki.fi>

        PR fortran/20363
        * gfortran.dg/named_interface.f90: New test.
-------------- next part --------------
? gcc/testsuite/gfortran.dg/named_interface.f90
Index: gcc/fortran/decl.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/decl.c,v
retrieving revision 1.37
diff -u -p -r1.37 decl.c
--- gcc/fortran/decl.c	6 Jul 2005 22:12:12 -0000	1.37
+++ gcc/fortran/decl.c	7 Jul 2005 23:27:54 -0000
@@ -530,29 +530,34 @@ syntax:
 }
 
 
-/* Special subroutine for finding a symbol.  If we're compiling a
-   function or subroutine and the parent compilation unit is an
-   interface, then check to see if the name we've been given is the
-   name of the interface (located in another namespace).  If so,
-   return that symbol.  If not, use gfc_get_symbol().  */
+/* Special subroutine for finding a symbol.  Check if the name is found
+   in the current name space.  If not, and we're compiling a function or
+   subroutine and the parent compilation unit is an interface, then check
+   to see if the name we've been given is the name of the interface
+   (located in another namespace).  */
 
 static int
 find_special (const char *name, gfc_symbol ** result)
 {
   gfc_state_data *s;
+  int i;
 
+  i = gfc_get_symbol (name, NULL, result);
+  if (i==0) 
+    goto end;
+  
   if (gfc_current_state () != COMP_SUBROUTINE
       && gfc_current_state () != COMP_FUNCTION)
-    goto normal;
+    goto end;
 
   s = gfc_state_stack->previous;
   if (s == NULL)
-    goto normal;
+    goto end;
 
   if (s->state != COMP_INTERFACE)
-    goto normal;
+    goto end;
   if (s->sym == NULL)
-    goto normal;		/* Nameless interface */
+    goto end;                  /* Nameless interface */
 
   if (strcmp (name, s->sym->name) == 0)
     {
@@ -560,8 +565,8 @@ find_special (const char *name, gfc_symb
       return 0;
     }
 
-normal:
-  return gfc_get_symbol (name, NULL, result);
+end:
+  return i;
 }
 
 
-------------- next part --------------
! { dg-do compile }
module snafu
  interface foo
    subroutine really_snafu (foo)        
      integer, intent (inout)  :: foo
    end subroutine really_snafu
  end interface foo
end module snafu


More information about the Fortran mailing list