This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[gfortran] Fold gfc_use_ha_derived into gfc_use_derived


There's no reason for the function gfc_use_ha_derived to exist (actually, it
is declared static, contrary to the FE's naming convention), as it is called
only in a single place: gfc_use_derived.  This patch folds both functions into
a single function.

Bubblestrapped and regtesting.  I will commit this as obvious once testing
finishes.  Seen while comparing our code to g95's.

- Tobi

Index: symbol.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/fortran/symbol.c,v
retrieving revision 1.19
diff -u -p -r1.19 symbol.c
--- symbol.c    7 Feb 2005 22:16:13 -0000       1.19
+++ symbol.c    12 Feb 2005 15:27:45 -0000
@@ -1201,14 +1201,17 @@ switch_types (gfc_symtree * st, gfc_symb
    pointer to the translated node or NULL for an error.  Usually there
    is no translation and we return the node we were passed.  */

-static gfc_symtree *
-gfc_use_ha_derived (gfc_symbol * sym)
+gfc_symbol *
+gfc_use_derived (gfc_symbol * sym)
 {
   gfc_symbol *s, *p;
   gfc_typespec *t;
   gfc_symtree *st;
   int i;

+  if (sym->components != NULL)
+    return sym;               /* Already defined.  */
+
   if (sym->ns->parent == NULL)
     goto bad;

@@ -1251,7 +1254,7 @@ gfc_use_ha_derived (gfc_symbol * sym)
      namelists, common lists and interface lists.  */
   gfc_free_symbol (sym);

-  return st;
+  return s;

 bad:
   gfc_error ("Derived type '%s' at %C is being used before it is defined",
@@ -1260,22 +1263,6 @@ bad:
 }


-gfc_symbol *
-gfc_use_derived (gfc_symbol * sym)
-{
-  gfc_symtree *st;
-
-  if (sym->components != NULL)
-    return sym;                        /* Already defined */
-
-  st = gfc_use_ha_derived (sym);
-  if (st)
-    return st->n.sym;
-  else
-    return NULL;
-}
-
-
 /* Given a derived type node and a component name, try to locate the
    component structure.  Returns the NULL pointer if the component is
    not found or the components are private.  */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]