* [PATCH,c++] convert decl_namespace_list into a VEC
@ 2010-06-06 17:25 Nathan Froyd
2010-06-08 14:07 ` Jason Merrill
0 siblings, 1 reply; 3+ messages in thread
From: Nathan Froyd @ 2010-06-06 17:25 UTC (permalink / raw)
To: gcc-patches
This patch converts decl_namespace_list into a VEC, eliminating a few
usages of TREE_LIST.
Tested on x86_64-unknown-linux-gnu. OK to commit?
-Nathan
* cp-tree.h (struct saved_scope): Change decl_ns_list field type
to a VEC.
* decl2.c (cp_write_global_declarations): Adjust for new type of
decl_namespace_list.
* name-lookup.c (current_decl_namespace): Likewise.
(push_decl_namespace): Likewise.
(pop_decl_namespace): Likewise.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 6b292b6..52934be 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -896,7 +896,7 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX];
struct GTY(()) saved_scope {
VEC(cxx_saved_binding,gc) *old_bindings;
tree old_namespace;
- tree decl_ns_list;
+ VEC(tree,gc) *decl_ns_list;
tree class_name;
tree class_type;
tree access_specifier;
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 33e0e26..26f5312 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -3589,7 +3589,8 @@ cp_write_global_declarations (void)
at_eof = 1;
/* Bad parse errors. Just forget about it. */
- if (! global_bindings_p () || current_class_type || decl_namespace_list)
+ if (! global_bindings_p () || current_class_type
+ || VEC_length (tree,decl_namespace_list) != 0)
return;
if (pch_file)
diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c
index 3236b64..2178902 100644
--- a/gcc/cp/name-lookup.c
+++ b/gcc/cp/name-lookup.c
@@ -3195,8 +3195,8 @@ current_decl_namespace (void)
{
tree result;
/* If we have been pushed into a different namespace, use it. */
- if (decl_namespace_list)
- return TREE_PURPOSE (decl_namespace_list);
+ if (VEC_length (tree, decl_namespace_list) != 0)
+ return VEC_last (tree, decl_namespace_list);
if (current_class_type)
result = decl_namespace_context (current_class_type);
@@ -3380,8 +3380,7 @@ push_decl_namespace (tree decl)
{
if (TREE_CODE (decl) != NAMESPACE_DECL)
decl = decl_namespace_context (decl);
- decl_namespace_list = tree_cons (ORIGINAL_NAMESPACE (decl),
- NULL_TREE, decl_namespace_list);
+ VEC_safe_push (tree, gc, decl_namespace_list, ORIGINAL_NAMESPACE (decl));
}
/* [namespace.memdef]/2 */
@@ -3389,7 +3388,7 @@ push_decl_namespace (tree decl)
void
pop_decl_namespace (void)
{
- decl_namespace_list = TREE_CHAIN (decl_namespace_list);
+ VEC_pop (tree, decl_namespace_list);
}
/* Return the namespace that is the common ancestor
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH,c++] convert decl_namespace_list into a VEC
2010-06-06 17:25 [PATCH,c++] convert decl_namespace_list into a VEC Nathan Froyd
@ 2010-06-08 14:07 ` Jason Merrill
2010-06-09 16:07 ` Nathan Froyd
0 siblings, 1 reply; 3+ messages in thread
From: Jason Merrill @ 2010-06-08 14:07 UTC (permalink / raw)
To: Nathan Froyd; +Cc: gcc-patches
On 06/06/2010 01:24 PM, Nathan Froyd wrote:
> + || VEC_length (tree,decl_namespace_list) != 0)
You might want to use !VEC_empty instead. OK either way.
Jason
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH,c++] convert decl_namespace_list into a VEC
2010-06-08 14:07 ` Jason Merrill
@ 2010-06-09 16:07 ` Nathan Froyd
0 siblings, 0 replies; 3+ messages in thread
From: Nathan Froyd @ 2010-06-09 16:07 UTC (permalink / raw)
To: Jason Merrill; +Cc: gcc-patches
On Tue, Jun 08, 2010 at 10:07:00AM -0400, Jason Merrill wrote:
> On 06/06/2010 01:24 PM, Nathan Froyd wrote:
>> + || VEC_length (tree,decl_namespace_list) != 0)
>
> You might want to use !VEC_empty instead. OK either way.
Thanks for pointing that out. Committed with using VEC_empty in both
places where it matters.
-Nathan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-06-09 15:35 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-06-06 17:25 [PATCH,c++] convert decl_namespace_list into a VEC Nathan Froyd
2010-06-08 14:07 ` Jason Merrill
2010-06-09 16:07 ` Nathan Froyd
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).