summaryrefslogtreecommitdiff
path: root/gcc/cp/ptree.c
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>1998-02-25 00:49:51 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>1998-02-25 00:49:51 +0000
commit18e99d0072ed35494b9936d289150b258ec33177 (patch)
treee73e02e4d84a416ffd3f786f3aac7b49634b0e88 /gcc/cp/ptree.c
parentdbcd93702964a7ed9a453702d492c2b7a4dc64f4 (diff)
downloadgcc-18e99d0072ed35494b9936d289150b258ec33177.tar.gz
Partial implementation of namespaces.
* decl.c (push_namespace): Handle redeclaration error. * cp-tree.h (IDENTIFIER_NAMESPACE_VALUE): New macro. (IDENTIFIER_NAMESPACE_BINDINGS): New macro. (NAMESPACE_BINDING): New macro. (IDENTIFIER_GLOBAL_VALUE): Use NAMESPACE_BINDING. * *.c: Use them. * pt.c (push_template_decl): Use innermost_args. * decl.c (get_unique_name): Tweak from earlier in the name. * cp-tree.def: Add CPLUS_BINDING node. * cp-tree.h (tree_binding): new struct (BINDING_SCOPE, BINDING_VALUE): new macros (current_namespace, global_namespace): declare extern (struct lang_decl_flags): new field in_namespace (DECL_NAMESPACE_USING, DECL_NAMESPACE_USERS): new macros (DECL_NAMESPACE, SET_DECL_NAMESPACE): new macros (TREE_INDIRECT_USING): new macro * decl2.c (current_namespace, global_namespace): Declare. The value is a NAMESPACE_DECL now, not a TREE_LIST. (is_namespace_ancestor, namespace_ancestor):new static functions. (add_using_namespace, ambiguous_decl): likewise. (lookup_using_namespace): new support function for lookup_name. (qualified_lookup_using_namespace): new support function for do_scoped_id and lookup_namespace_name (get_namespace_id): mark as obsolete. (current_namespace_id): Likewise. (do_namespace_alias): Implement. (do_using_directive): Implement as call to add_using_namespace. * decl.c (binding_for_name): new function. (push_namespace, pop_namespace): implement. (push_decl): don't install a FUNCTION_DECL in the global branch. (lookup_namespace_name): implement using qualified lookup. (lookup_name_real): For global scoping, lookup in global_namespace. For namespace scoping, lookup in given namespace. For unscoped lookup, iterate over namespace, considering using directives. (init_decl_processing): initialize global_namespace. (grokvardecl): Build assembler name as static name for globals. (grokdeclarator): Remove old namespace mangling. (xref_tag): When installing a global binding for the tag, make sure we have an identifier. * method.c (build_overload_nested_name): mangle namespaces. (build_qualified_name): Likewise. (build_decl_overload_real): Likewise. * lex.c (build_lang_decl): set namespace for new declaration to current_namespace. (do_scoped_id): find global names in global or current namespace, or using qualified namespace lookup, depending on context. * init.c (build_member_call): When scope is namespace, use build_x_function_call instead. (build_offset_ref): When scope is namespace, collapse processing to lookup_namespace_name instead. * error.c (dump_decl): Support NAMESPACE_DECL. * decl.c (pushdecl): Bind globals to current namespace. (push_overloaded_decl): Likewise. (lookup_tag): Likewise. (lookup_name_current_level): Likewise. (xref_tag): Likewise. (start_function): Likewise. * lex.c (do_identifier): Likewise. (identifier_typedecl_value): Likewise. (real_yylex): Likewise. * method.c (do_inline_function_hair): Likewise. * parse.y (unscoped): Likewise. * pt.c (check_explicit_specialization): Likewise. (lookup_template_class): Likewise. * rtti.c (call_void_fn): Likewise. * sig.c (build_sigtable): Likewise. * ptree.c (lang_print_xnode): New function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@18227 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cp/ptree.c')
-rw-r--r--gcc/cp/ptree.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/gcc/cp/ptree.c b/gcc/cp/ptree.c
index 4a6ce7bfaeb..13f171aa0a1 100644
--- a/gcc/cp/ptree.c
+++ b/gcc/cp/ptree.c
@@ -163,3 +163,21 @@ print_lang_identifier (file, node, indent)
print_node (file, "implicit", IDENTIFIER_IMPLICIT_DECL (node), indent + 4);
print_node (file, "error locus", IDENTIFIER_ERROR_LOCUS (node), indent + 4);
}
+
+void
+lang_print_xnode (file, node, indent)
+ FILE *file;
+ tree node;
+ int indent;
+{
+ switch (TREE_CODE (node))
+ {
+ case CPLUS_BINDING:
+ print_node (file, "scope", BINDING_SCOPE (node), indent+4);
+ print_node (file, "value", BINDING_VALUE (node), indent+4);
+ print_node (file, "chain", TREE_CHAIN (node), indent+4);
+ break;
+ default:
+ break;
+ }
+}