gcc/gcc/cp/ptree.c

209 lines
6.3 KiB
C
Raw Normal View History

1994-02-24 02:02:37 +01:00
/* Prints out trees in human readable form.
Copyright (C) 1992, 93-96, 1998, 1999 Free Software Foundation, Inc.
1994-02-24 02:02:37 +01:00
Hacked by Michael Tiemann (tiemann@cygnus.com)
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
1995-06-15 14:29:51 +02:00
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
1994-02-24 02:02:37 +01:00
#include "config.h"
#include "system.h"
#include "tree.h"
1994-02-24 02:02:37 +01:00
#include "cp-tree.h"
void
print_lang_decl (file, node, indent)
FILE *file;
tree node;
int indent;
{
if (!DECL_LANG_SPECIFIC (node))
return;
/* A FIELD_DECL only has the flags structure, which we aren't displaying
anyways. */
if (DECL_MUTABLE_P (node))
{
indent_to (file, indent + 3);
fprintf (file, " mutable ");
}
if (TREE_CODE (node) == FIELD_DECL)
return;
indent_to (file, indent + 3);
if (DECL_MAIN_VARIANT (node))
{
fprintf (file, " decl-main-variant ");
fprintf (file, HOST_PTR_PRINTF, DECL_MAIN_VARIANT (node));
}
if (TREE_CODE (node) == FUNCTION_DECL
&& DECL_PENDING_INLINE_INFO (node))
1994-02-24 02:02:37 +01:00
{
fprintf (file, " pending-inline-info ");
fprintf (file, HOST_PTR_PRINTF, DECL_PENDING_INLINE_INFO (node));
}
if (TREE_CODE (node) == TYPE_DECL
&& DECL_SORTED_FIELDS (node))
{
fprintf (file, " sorted-fields ");
fprintf (file, HOST_PTR_PRINTF, DECL_SORTED_FIELDS (node));
}
1994-02-24 02:02:37 +01:00
if (DECL_TEMPLATE_INFO (node))
{
fprintf (file, " template-info ");
fprintf (file, HOST_PTR_PRINTF, DECL_TEMPLATE_INFO (node));
}
}
void
print_lang_type (file, node, indent)
FILE *file;
register tree node;
int indent;
{
switch (TREE_CODE (node))
1994-02-24 02:02:37 +01:00
{
case TEMPLATE_TYPE_PARM:
case TEMPLATE_TEMPLATE_PARM:
Support for friend templates. * typeck.c (build_x_function_call): Handle static member function templates like non-templates. Handle friend templates like normal function templates. * pt.c (tsubst, *_PARM): Don't use orig_level. (get_bindings): Don't call add_to_template_args. (instantiate_template): Likewise. (tsubst, FUNCTION_DECL): Call add_to_template_args as appropriate. * ptree.c (print_lang_type): Print index/level for template parms. * Make-lang.in (cc1plus): Note that cc1plus depends on cp/cp-tree.h and cp/cp-tree.def. * cp-tree.def (TEMPLATE_CONST_PARM): Remove. (TEMPLATE_PARM_INDEX): New tree code, used to indicate a position in a template parameter list. * cp-tree.h (template_parm_index): New structure, used as the tree structure for a TEMPLATE_PARM_INDEX. (TEMPLATE_PARM_IDX): New macro. (TEMPLATE_PARM_LEVEL): Likewise. (TEMPLATE_PARM_DESCENDANTS): Likewise. (TEMPLATE_PARM_ORIG_LEVEL): Likewise. (TEMPLATE_PARM_DECL): Likewise. (TEMPLATE_TYPE_PARM_INDEX): Likewise. (TEMPLATE_TYPE_ORIG_LEVEL): Likewise. (TEMPLATE_TYPE_DECL): Likewise. (TEMPLATE_CONST_IDX): Remove. (TEMPLATE_CONST_LEVEL): Likewise. (TEMPLATE_CONST_SET_INFO): Likewise. (TEMPLATE_TYPE_SET_INFO): Likewise. (TEMPLATE_TYPE_IDX): Redefine in terms of TEMPLATE_PARM_INDEX node. (TEMPLATE_TYPE_LEVEL): Likewise. * decl.c (decls_match): Call comp_template_parms, rather than expanding it inline. (duplicate_decls): If two template declarations are being merged, then their TEMPLATE_INFOs should be merged as well. (grokfndecl): Save template-id information when declaring a friend with explicit template arguments. Pass arguments to check_explicit_specialization via correct convention; at some point check_explicit_specialization changed, but these call-sites did not. (grokdeclarator): Tidy up slightly. * decl2.c (check_classfn): Tidy up slightly. Don't assume that two template functions with the same DECL_ASSEMBLER_NAME the same, since the names are not yet mangled. * error.c (dump_decl): Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM. (dump_expr): Likewise. Use the TEMPLATE_PARM_DECL to get at the decl for a non-type parameter, rather than printing `<tparm ...>'. * friend.c (is_friend): Handle TEMPLATE_DECL friends. (do_friend): Deal with template friends. * lex.c (do_pending_inlines): Call maybe_begin_member_template_processing, rather than conditionally calling begin_member_template_processing. (process_next_inline): Likewise. Call maybe_end_member_template_processing, rather than conditionally calling end_member_template_processing. (do_pending_defargs): Likewise. (do_identifier): Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM. * method.c (build_mangled_template_parm_index): New function. (build_overload_value): Use it. (build_overload_name): Likewise. * pt.c (finish_member_template_decl): Allow friend declarations. (template_class_depth): New function. (is_member_template): Rename, and modify, to become... (is_member_or_friend_template): New function. (end_member_template_processing): Rename, and modify, to become... (maybe_end_member_template_processing). (build_template_parm_index): New function. (reduce_template_parm_level): New function. (process_template_parm): Modify to use build_template_parm_index. (current_template_args): Change name to current_template_parms. (push_template_decl): Deal with friend templates. (uses_template_parms): Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM. (tsubst_friend_function): New function. (instantiate_class_template): Generate the DECL_FRIENDLIST for a new instantiation by using tsubst_friend_function rather than just tsubst. (tsubst): Don't tsubst into a type which is a TEMPLATE_DECL. Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM, and the appropriate new macros. Use reduce_template_parm_level to generate lower-level template parameters. Handle tsubst'ing into TEMPLATE_DECLS that declare TEMPLATE_TEMPLATE_PARMS. Don't forget to tsubst the DECL_CONTEXT and DECL_CLASS_CONTEXT of newly created templates. Similarly for the template parameters for a new template. (tsubst_copy): Tidy up slightly. Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM. Handle TYPE_DECLs by tsubsting into them. (unify): Use TEMPLATE_PARM_INDEX instead of TEMPLATE_CONST_PARM. (get_bindings): Call add_to_template_args if necessary. (instantiate_decl): Handle instantiations of friend templates. * search.c (lookup_field_1): Don't treat the TYPE_FIELDS of a TEMPLATE_TYPE_PARM as a list of fields; it's not! * spew.c (yylex): Do a little manual constant propogation to clarify the code. From-SVN: r18198
1998-02-23 04:17:44 +01:00
indent_to (file, indent + 3);
fputs ("index ", file);
fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_TYPE_IDX (node));
fputs (" level ", file);
fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_TYPE_LEVEL (node));
fputs (" orig_level ", file);
fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_TYPE_ORIG_LEVEL (node));
1994-02-24 02:02:37 +01:00
return;
case FUNCTION_TYPE:
case METHOD_TYPE:
if (TYPE_RAISES_EXCEPTIONS (node))
print_node (file, "throws", TYPE_RAISES_EXCEPTIONS (node), indent + 4);
return;
case RECORD_TYPE:
case UNION_TYPE:
break;
default:
return;
1994-02-24 02:02:37 +01:00
}
if (TYPE_PTRMEMFUNC_P (node))
print_node (file, "ptrmemfunc fn type", TYPE_PTRMEMFUNC_FN_TYPE (node),
indent + 4);
if (! CLASS_TYPE_P (node))
1994-02-24 02:02:37 +01:00
return;
indent_to (file, indent + 3);
if (TYPE_NEEDS_CONSTRUCTING (node))
fputs ( "needs-constructor", file);
if (TYPE_NEEDS_DESTRUCTOR (node))
fputs (" needs-destructor", file);
if (TYPE_HAS_DESTRUCTOR (node))
fputs (" ~X()", file);
if (TYPE_HAS_DEFAULT_CONSTRUCTOR (node))
fputs (" X()", file);
if (TYPE_HAS_CONVERSION (node))
fputs (" has-type-conversion", file);
if (TYPE_HAS_INIT_REF (node))
{
if (TYPE_HAS_CONST_INIT_REF (node))
fputs (" X(constX&)", file);
else
fputs (" X(X&)", file);
}
if (TYPE_GETS_NEW (node) & 1)
fputs (" new", file);
if (TYPE_GETS_NEW (node) & 2)
fputs (" new[]", file);
if (TYPE_GETS_DELETE (node) & 1)
fputs (" delete", file);
if (TYPE_GETS_DELETE (node) & 2)
fputs (" delete[]", file);
1994-02-24 02:02:37 +01:00
if (TYPE_HAS_ASSIGN_REF (node))
fputs (" this=(X&)", file);
if (TYPE_OVERLOADS_CALL_EXPR (node))
fputs (" op()", file);
if (TYPE_OVERLOADS_ARRAY_REF (node))
fputs (" op[]", file);
if (TYPE_OVERLOADS_ARROW (node))
fputs (" op->", file);
if (TYPE_USES_MULTIPLE_INHERITANCE (node))
fputs (" uses-multiple-inheritance", file);
if (TREE_CODE (node) == RECORD_TYPE)
{
fprintf (file, " n_parents %d", CLASSTYPE_N_BASECLASSES (node));
1994-02-24 02:02:37 +01:00
fprintf (file, " use_template=%d", CLASSTYPE_USE_TEMPLATE (node));
if (CLASSTYPE_INTERFACE_ONLY (node))
fprintf (file, " interface-only");
if (CLASSTYPE_INTERFACE_UNKNOWN (node))
fprintf (file, " interface-unknown");
if (CLASSTYPE_VTABLE_NEEDS_WRITING (node))
fprintf (file, " vtable-needs-writing");
1994-02-24 02:02:37 +01:00
print_node (file, "member-functions", CLASSTYPE_METHOD_VEC (node),
indent + 4);
}
}
void
print_lang_identifier (file, node, indent)
FILE *file;
tree node;
int indent;
{
print_node (file, "bindings", IDENTIFIER_NAMESPACE_BINDINGS (node), indent + 4);
1994-02-24 02:02:37 +01:00
print_node (file, "class", IDENTIFIER_CLASS_VALUE (node), indent + 4);
cp-tree.def (CPLUS_BINDING): Update documentation. * cp-tree.def (CPLUS_BINDING): Update documentation. * cp-tree.h (LOCAL_BINDING_P): New macro. (lang_identifier): Rename local_value to bindings. (tree_binding): Make `scope' of type `void*', not `tree'. (BINDING_SCOPE): Update documentation. (IDENTIFIER_LOCAL_VALUE): Remove. (IDENTIFIER_CLASS_VALUE): Document. (IDENTIFIER_BINDING): New macro. (IDENTIFIER_VALUE): Likewise. (TIME_IDENTIFIER_TIME): Likewise. (TIME_IDENTIFIER_FILEINFO): Likewise. (IMPLICIT_TYPENAME_P): Likewise. (set_identifier_local_value): Remove. (push_local_binding): New function. (push_class_binding): Likewise. * class.c (pushclass): Update comments; use push_class_binding. * decl.c (set_identifier_local_value_with_scope): Remove. (set_identifier_local_value): Likewise. (push_binding): New function. (pop_binding): Likewise. (binding_level): Update documentation. Remove shadowed. (BINDING_LEVEL): New macro. (free_binding_nodes): New variable. (poplevel): Adjust for new name-lookup scheme. Don't mess up BLOCK_VARs when doing for-scope extension. Remove effectively dead code. (pushlevel_class): Tweak formatting. (poplevel_class): Adjust for new name-lookup scheme. (print_binding_level): Likewise. (store_bindings): Likewise. (pushdecl): Likewise. (pushdecl_class_level): Likewise. (push_class_level_binding): Likewise. (push_overloaded_decl): Update comments. Adjust for new name-lookup scheme. (lookup_name_real): Likewise. (lookup_name_current_level): Likewise. (cp_finish_decl): Likewise. (require_complete_types_for_parms): Likewise. Remove misleading #if 0'd code. (grok_parms): Likewise. Don't call require_complete_types_for_parms here. (grok_ctor_properties): Don't treat templates as copy constructors. (grop_op_properties): Or as assignment operators. (start_function): Document. Adjust for new name-lookup scheme. (finish_function): Likewise. * decl2.c (do_local_using_decl): Use push_local_binding. * lex.c (begin_definition_of_inclass_inline): New function, split out from ... (do_pending_inlines): Here, and ... (process_next_inline): Here. (get_time_identifier): Use TIME_IDENTIFIER_* macros. (init_filename_times): Likewise. (extract_interface_info): Likewise. (ste_typedecl_interface_info): Likewise. (check_newline): Likewise. (dump_time_statistics): Likewise. (handle_cp_pragma): Likewise. (do_identifier): Adjust for new name-lookup scheme. * parse.y (function_try_block): Return ctor_initializer_opt value. (fndef): Use it. (fn.defpen): Pass appropriate values to start_function. (pending_inline): Use functor_try_block value, and pass appropriate values to finish_function. * pt.c (is_member_template): Update documentation; remove handling of FUNCTION_DECLs. As per name, this function should deal only in TEMPLATE_DECLs. (decl_template_parm_p): Change name of olddecl parameter to decl. (check_template_shadow): Adjust for new name-lookup scheme. (lookup_template_class): Likewise. (tsubst_decl): Tweak so as not to confuse member templates with copy constructors and assignment operators. (unify): Handle UNION_TYPEs. * ptree.c (print_lang_identifier): Adjust for new name-lookup scheme. (lang_print_xnode): Adjust for new name-lookup scheme. * typeck.c (mark_addressable): Likewise. (c_expand_return): Likewise. From-SVN: r24296
1998-12-13 15:46:07 +01:00
print_node (file, "local bindings", IDENTIFIER_BINDING (node), indent + 4);
1994-02-24 02:02:37 +01:00
print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);
print_node (file, "template", IDENTIFIER_TEMPLATE (node), indent + 4);
print_node (file, "implicit", IDENTIFIER_IMPLICIT_DECL (node), indent + 4);
print_node (file, "error locus", IDENTIFIER_ERROR_LOCUS (node), indent + 4);
}
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. From-SVN: r18227
1998-02-25 01:49:51 +01:00
void
lang_print_xnode (file, node, indent)
FILE *file;
tree node;
int indent;
{
switch (TREE_CODE (node))
{
case CPLUS_BINDING:
cp-tree.def (CPLUS_BINDING): Update documentation. * cp-tree.def (CPLUS_BINDING): Update documentation. * cp-tree.h (LOCAL_BINDING_P): New macro. (lang_identifier): Rename local_value to bindings. (tree_binding): Make `scope' of type `void*', not `tree'. (BINDING_SCOPE): Update documentation. (IDENTIFIER_LOCAL_VALUE): Remove. (IDENTIFIER_CLASS_VALUE): Document. (IDENTIFIER_BINDING): New macro. (IDENTIFIER_VALUE): Likewise. (TIME_IDENTIFIER_TIME): Likewise. (TIME_IDENTIFIER_FILEINFO): Likewise. (IMPLICIT_TYPENAME_P): Likewise. (set_identifier_local_value): Remove. (push_local_binding): New function. (push_class_binding): Likewise. * class.c (pushclass): Update comments; use push_class_binding. * decl.c (set_identifier_local_value_with_scope): Remove. (set_identifier_local_value): Likewise. (push_binding): New function. (pop_binding): Likewise. (binding_level): Update documentation. Remove shadowed. (BINDING_LEVEL): New macro. (free_binding_nodes): New variable. (poplevel): Adjust for new name-lookup scheme. Don't mess up BLOCK_VARs when doing for-scope extension. Remove effectively dead code. (pushlevel_class): Tweak formatting. (poplevel_class): Adjust for new name-lookup scheme. (print_binding_level): Likewise. (store_bindings): Likewise. (pushdecl): Likewise. (pushdecl_class_level): Likewise. (push_class_level_binding): Likewise. (push_overloaded_decl): Update comments. Adjust for new name-lookup scheme. (lookup_name_real): Likewise. (lookup_name_current_level): Likewise. (cp_finish_decl): Likewise. (require_complete_types_for_parms): Likewise. Remove misleading #if 0'd code. (grok_parms): Likewise. Don't call require_complete_types_for_parms here. (grok_ctor_properties): Don't treat templates as copy constructors. (grop_op_properties): Or as assignment operators. (start_function): Document. Adjust for new name-lookup scheme. (finish_function): Likewise. * decl2.c (do_local_using_decl): Use push_local_binding. * lex.c (begin_definition_of_inclass_inline): New function, split out from ... (do_pending_inlines): Here, and ... (process_next_inline): Here. (get_time_identifier): Use TIME_IDENTIFIER_* macros. (init_filename_times): Likewise. (extract_interface_info): Likewise. (ste_typedecl_interface_info): Likewise. (check_newline): Likewise. (dump_time_statistics): Likewise. (handle_cp_pragma): Likewise. (do_identifier): Adjust for new name-lookup scheme. * parse.y (function_try_block): Return ctor_initializer_opt value. (fndef): Use it. (fn.defpen): Pass appropriate values to start_function. (pending_inline): Use functor_try_block value, and pass appropriate values to finish_function. * pt.c (is_member_template): Update documentation; remove handling of FUNCTION_DECLs. As per name, this function should deal only in TEMPLATE_DECLs. (decl_template_parm_p): Change name of olddecl parameter to decl. (check_template_shadow): Adjust for new name-lookup scheme. (lookup_template_class): Likewise. (tsubst_decl): Tweak so as not to confuse member templates with copy constructors and assignment operators. (unify): Handle UNION_TYPEs. * ptree.c (print_lang_identifier): Adjust for new name-lookup scheme. (lang_print_xnode): Adjust for new name-lookup scheme. * typeck.c (mark_addressable): Likewise. (c_expand_return): Likewise. From-SVN: r24296
1998-12-13 15:46:07 +01:00
fprintf (file, " scope ");
fprintf (file, HOST_PTR_PRINTF, BINDING_SCOPE (node));
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. From-SVN: r18227
1998-02-25 01:49:51 +01:00
print_node (file, "value", BINDING_VALUE (node), indent+4);
print_node (file, "chain", TREE_CHAIN (node), indent+4);
break;
case OVERLOAD:
print_node (file, "function", OVL_FUNCTION (node), indent+4);
print_node (file, "chain", TREE_CHAIN (node), indent+4);
break;
case TEMPLATE_PARM_INDEX:
indent_to (file, indent + 3);
fputs ("index ", file);
fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_PARM_IDX (node));
fputs (" level ", file);
fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_PARM_LEVEL (node));
fputs (" orig_level ", file);
fprintf (file, HOST_WIDE_INT_PRINT_DEC, TEMPLATE_PARM_ORIG_LEVEL (node));
break;
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. From-SVN: r18227
1998-02-25 01:49:51 +01:00
default:
break;
}
}