OSDN Git Service

* decl.c (cp_binding_level): Add static_decls varray member.
authoraustern <austern@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 5 Mar 2003 22:08:39 +0000 (22:08 +0000)
committeraustern <austern@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 5 Mar 2003 22:08:39 +0000 (22:08 +0000)
(add_decl_to_level): Add static/inline namespace scope
declarations to static_decls array.
(wrapup_global_for_namespace): Pass static_decls only, instead of
all decls, to wrapup_global_declarations/check_global_declarations.
(push_namespace): Initialize static_decls for ordinary namespaces.
(cxx_init_decl_processing): Initialize static_decls for global
namespace.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@63866 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/decl.c

index a57faa9..d874ac0 100644 (file)
@@ -1,3 +1,14 @@
+2003-03-02  Matt Austern  <austern@apple.com>
+
+       * decl.c (cp_binding_level): Add static_decls varray member.
+       (add_decl_to_level): Add static/inline namespace scope
+       declarations to static_decls array.
+       (wrapup_global_for_namespace): Pass static_decls only, instead of
+       all decls, to wrapup_global_declarations/check_global_declarations.
+       (push_namespace): Initialize static_decls for ordinary namespaces.
+       (cxx_init_decl_processing): Initialize static_decls for global
+       namespace.
+       
 2003-03-05  Mark Mitchell  <mark@codesourcery.com>
 
        * class.c (end_of_class): Correct thinko.
index 90058e7..a320ef0 100644 (file)
@@ -327,6 +327,9 @@ struct cp_binding_level GTY(())
     /* A chain of NAMESPACE_DECL nodes.  */
     tree namespaces;
 
+    /* An array of static functions and variables (for namespaces only) */
+    varray_type static_decls;
+
     /* A chain of VTABLE_DECL nodes.  */
     tree vtables; 
 
@@ -1019,6 +1022,13 @@ add_decl_to_level (tree decl,
       TREE_CHAIN (decl) = b->names;
       b->names = decl;
       b->names_size++;
+
+      /* If appropriate, add decl to separate list of statics */
+      if (b->namespace_p)
+       if ((TREE_CODE (decl) == VAR_DECL && TREE_STATIC (decl))
+           || (TREE_CODE (decl) == FUNCTION_DECL
+               && (!TREE_PUBLIC (decl) || DECL_DECLARED_INLINE_P (decl))))
+         VARRAY_PUSH_TREE (b->static_decls, decl);
     }
 }
 
@@ -1849,19 +1859,12 @@ walk_globals (walk_globals_pred p, walk_globals_fn f, void *data)
 int
 wrapup_globals_for_namespace (tree namespace, void* data)
 {
-  tree globals = cp_namespace_decls (namespace);
-  int len = NAMESPACE_LEVEL (namespace)->names_size;
-  tree *vec = (tree *) alloca (sizeof (tree) * len);
-  int i;
-  int result;
-  tree decl;
+  struct cp_binding_level *level = NAMESPACE_LEVEL (namespace);
+  varray_type statics = level->static_decls;
+  tree *vec = &VARRAY_TREE (statics, 0);
+  int len = VARRAY_ACTIVE_SIZE (statics);
   int last_time = (data != 0);
 
-  /* Process the decls in reverse order--earliest first.
-     Put them into VEC from back to front, then take out from front.  */       
-  for (i = 0, decl = globals; i < len; i++, decl = TREE_CHAIN (decl))
-    vec[len - i - 1] = decl;
-
   if (last_time)
     {
       check_global_declarations (vec, len);
@@ -1869,9 +1872,7 @@ wrapup_globals_for_namespace (tree namespace, void* data)
     }
 
   /* Write out any globals that need to be output.  */
-  result = wrapup_global_declarations (vec, len);
-
-  return result;
+  return wrapup_global_declarations (vec, len);
 }
 
 \f
@@ -2195,6 +2196,9 @@ push_namespace (tree name)
          pushlevel (0);
          declare_namespace_level ();
          NAMESPACE_LEVEL (d) = current_binding_level;
+         VARRAY_TREE_INIT (current_binding_level->static_decls,
+                           name != std_identifier ? 10 : 200,
+                           "Static declarations");
        }
     }
   else
@@ -6323,6 +6327,10 @@ cxx_init_decl_processing (void)
   NAMESPACE_LEVEL (global_namespace) = global_binding_level;
   declare_namespace_level ();
 
+  VARRAY_TREE_INIT (global_binding_level->static_decls,
+                   200,
+                   "Static declarations");
+
   /* Create the `std' namespace.  */
   push_namespace (std_identifier);
   std_node = current_namespace;