aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMatt Austern <austern@apple.com>2003-03-05 22:08:39 +0000
committerMatt Austern <austern@gcc.gnu.org>2003-03-05 22:08:39 +0000
commit1d555f7aecf2802ae7f21891aea9d3de0407c88b (patch)
treeb7d625569420453dc5ec062beba56a278188f78c /gcc
parent35b0708052ed3381ee58d4e6251e3e43da411a4e (diff)
downloadgcc-1d555f7aecf2802ae7f21891aea9d3de0407c88b.zip
gcc-1d555f7aecf2802ae7f21891aea9d3de0407c88b.tar.gz
gcc-1d555f7aecf2802ae7f21891aea9d3de0407c88b.tar.bz2
decl.c (cp_binding_level): Add static_decls varray member.
* 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. From-SVN: r63866
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog11
-rw-r--r--gcc/cp/decl.c36
2 files changed, 33 insertions, 14 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index a57faa9..d874ac0 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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.
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 90058e7..a320ef0 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -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);
}
@@ -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;