From: mmitchel Date: Tue, 25 Jun 2002 15:35:27 +0000 (+0000) Subject: * call.c (build_op_delete_call): Use BASELINK_FUNCTIONS. X-Git-Url: http://git.sourceforge.jp/view?a=commitdiff_plain;h=8042247d65e4491617d085d7e4099899daa1fc94;p=pf3gnuchains%2Fgcc-fork.git * call.c (build_op_delete_call): Use BASELINK_FUNCTIONS. * class.c (handle_using_decl): Likewise. (instantiate_type): Likewise. * cp-tree.h (BASELINK_FUNCTIONS): New macro. (xref_basetypes): Change prototype. (begin_mem_initializers): New function. (get_overloaded_fn): Likewise. * decl.c (xref_basetypes): Simplify. * error.c (dump_expr): Use BASELINK_FUNCTIONS. * init.c (build_offset_ref): Likewise. * parse.y (base_init): Use begin_mem_initializers(). (structsp): Adjust call to xref_basetypes. * pt.c (determine_specialization): Use BASELINK_FUNCTIONS. (instantiate_class_template): Adjust call to xref_basetypes. * semantics.c (begin_mem_initializers): New function. * tree.c (is_overloaded_fn): Use BASELINK_FUNCTIONS. (really_overlaoded_fn): Likewise. (get_overloaded_fn): New function.' (get_first_fn): USe BASELINK_FUNCTIONS. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@54989 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 869c2554c08..891f96273d7 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,25 @@ +2002-06-25 Mark Mitchell + + * call.c (build_op_delete_call): Use BASELINK_FUNCTIONS. + * class.c (handle_using_decl): Likewise. + (instantiate_type): Likewise. + * cp-tree.h (BASELINK_FUNCTIONS): New macro. + (xref_basetypes): Change prototype. + (begin_mem_initializers): New function. + (get_overloaded_fn): Likewise. + * decl.c (xref_basetypes): Simplify. + * error.c (dump_expr): Use BASELINK_FUNCTIONS. + * init.c (build_offset_ref): Likewise. + * parse.y (base_init): Use begin_mem_initializers(). + (structsp): Adjust call to xref_basetypes. + * pt.c (determine_specialization): Use BASELINK_FUNCTIONS. + (instantiate_class_template): Adjust call to xref_basetypes. + * semantics.c (begin_mem_initializers): New function. + * tree.c (is_overloaded_fn): Use BASELINK_FUNCTIONS. + (really_overlaoded_fn): Likewise. + (get_overloaded_fn): New function.' + (get_first_fn): USe BASELINK_FUNCTIONS. + 2002-06-24 Mark Mitchell * cp-tree.h (SCALAR_TYPE_P): New macro. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index ed6ab2e3f1b..e6f31510d77 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -3698,7 +3698,7 @@ build_op_delete_call (code, addr, size, flags, placement) /* Go through the `operator delete' functions looking for one with a matching type. */ - for (fn = BASELINK_P (fns) ? TREE_VALUE (fns) : fns; + for (fn = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns; fn; fn = OVL_NEXT (fn)) { diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 0577c76cd2a..aa3caa13b24 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1235,7 +1235,7 @@ handle_using_decl (using_decl, t) if (BASELINK_P (fdecl)) /* Ignore base type this came from. */ - fdecl = TREE_VALUE (fdecl); + fdecl = BASELINK_FUNCTIONS (fdecl); old_value = IDENTIFIER_CLASS_VALUE (name); if (old_value) @@ -6139,7 +6139,7 @@ instantiate_type (lhstype, rhs, flags) case OFFSET_REF: rhs = TREE_OPERAND (rhs, 1); if (BASELINK_P (rhs)) - return instantiate_type (lhstype, TREE_VALUE (rhs), + return instantiate_type (lhstype, BASELINK_FUNCTIONS (rhs), flags | allow_ptrmem); /* This can happen if we are forming a pointer-to-member for a @@ -6175,7 +6175,7 @@ instantiate_type (lhstype, rhs, flags) /* Now we should have a baselink. */ my_friendly_assert (BASELINK_P (rhs), 990412); - return instantiate_type (lhstype, TREE_VALUE (rhs), flags); + return instantiate_type (lhstype, BASELINK_FUNCTIONS (rhs), flags); case CALL_EXPR: /* This is too hard for now. */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 32b24126711..7f21c9c87f7 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -385,6 +385,10 @@ struct tree_overload GTY(()) (TREE_CODE (NODE) == TREE_LIST && TREE_LANG_FLAG_1 (NODE)) #define SET_BASELINK_P(NODE) \ (TREE_LANG_FLAG_1 (NODE) = 1) +/* The functions referred to by the BASELINK; either a FUNCTION_DECL + or an OVERLOAD. */ +#define BASELINK_FUNCTIONS(NODE) \ + (TREE_VALUE (NODE)) #define WRAPPER_ZC(NODE) (((struct tree_wrapper*)WRAPPER_CHECK (NODE))->z_c) @@ -3854,7 +3858,7 @@ extern int grok_ctor_properties PARAMS ((tree, tree)); extern void grok_op_properties PARAMS ((tree, int)); extern tree xref_tag PARAMS ((tree, tree, int)); extern tree xref_tag_from_type PARAMS ((tree, tree, int)); -extern void xref_basetypes PARAMS ((tree, tree, tree, tree)); +extern void xref_basetypes PARAMS ((tree, tree)); extern tree start_enum PARAMS ((tree)); extern void finish_enum PARAMS ((tree)); extern void build_enumerator PARAMS ((tree, tree, tree)); @@ -4306,6 +4310,7 @@ extern void expand_body PARAMS ((tree)); extern tree nullify_returns_r PARAMS ((tree *, int *, void *)); extern void do_pushlevel PARAMS ((void)); extern tree do_poplevel PARAMS ((void)); +extern void begin_mem_initializers (void); extern void finish_mem_initializers PARAMS ((tree)); extern void setup_vtbl_ptr PARAMS ((tree, tree)); extern void clear_out_block PARAMS ((void)); @@ -4355,6 +4360,7 @@ extern tree make_binfo PARAMS ((tree, tree, tree, tree)); extern tree reverse_path PARAMS ((tree)); extern int count_functions PARAMS ((tree)); extern int is_overloaded_fn PARAMS ((tree)); +extern tree get_overloaded_fn PARAMS ((tree)); extern tree get_first_fn PARAMS ((tree)); extern int bound_pmf_p PARAMS ((tree)); extern tree ovl_cons PARAMS ((tree, tree)); diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 3a6e7a1f273..1b1975a0ac1 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -12983,9 +12983,7 @@ xref_tag_from_type (old, id, globalize) struct, or union. */ void -xref_basetypes (code_type_node, name, ref, binfo) - tree code_type_node; - tree name ATTRIBUTE_UNUSED; +xref_basetypes (ref, binfo) tree ref; tree binfo; { @@ -12997,21 +12995,14 @@ xref_basetypes (code_type_node, name, ref, binfo) int i, len; enum tag_types tag_code; - /* If we are called from the parser, code_type_node will sometimes be a - TREE_LIST. This indicates that the user wrote - "class __attribute__ ((foo)) bar". Extract the attributes so that - tree_low_cst doesn't crash. */ - if (TREE_CODE (code_type_node) == TREE_LIST) - code_type_node = TREE_VALUE (code_type_node); - - tag_code = (enum tag_types) tree_low_cst (code_type_node, 1); - - if (tag_code == union_type) + if (TREE_CODE (ref) == UNION_TYPE) { error ("derived union `%T' invalid", ref); return; } + tag_code = (CLASSTYPE_DECLARED_CLASS (ref) ? class_type : record_type); + len = list_length (binfo); /* First, make sure that any templates in base-classes are diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 15a7c94809b..678ffd081fb 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1882,7 +1882,8 @@ dump_expr (t, flags) /* A::f */ dump_expr (t, flags | TFF_EXPR_IN_PARENS); else if (BASELINK_P (t)) - dump_expr (OVL_CURRENT (TREE_VALUE (t)), flags | TFF_EXPR_IN_PARENS); + dump_expr (OVL_CURRENT (BASELINK_FUNCTIONS (t)), + flags | TFF_EXPR_IN_PARENS); else dump_decl (t, flags); } diff --git a/gcc/cp/init.c b/gcc/cp/init.c index b8ec78a28fb..0c34c0517ff 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -1671,7 +1671,7 @@ build_offset_ref (type, name) { /* Go from the TREE_BASELINK to the member function info. */ tree fnfields = member; - t = TREE_VALUE (fnfields); + t = BASELINK_FUNCTIONS (fnfields); if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR) { diff --git a/gcc/cp/parse.y b/gcc/cp/parse.y index acb45abbb81..14e5c5c2b06 100644 --- a/gcc/cp/parse.y +++ b/gcc/cp/parse.y @@ -945,14 +945,11 @@ return_init: ; base_init: - ':' member_init_list + ':' { begin_mem_initializers (); } member_init_list { - if (! DECL_CONSTRUCTOR_P (current_function_decl)) - error ("only constructors take base initializers"); - else if ($2.new_type_flag == 0) + if ($3.new_type_flag == 0) error ("no base or member initializers given following ':'"); - - finish_mem_initializers ($2.t); + finish_mem_initializers ($3.t); } ; @@ -2334,7 +2331,7 @@ structsp: a TYPENAME_TYPE with a type. */ type = TREE_TYPE (type); maybe_process_partial_specialization (type); - xref_basetypes (current_aggr, $1.t, type, $2); + xref_basetypes (type, $2); } $1.t = begin_class_definition (TREE_TYPE ($1.t)); check_class_key (current_aggr, $1.t); diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index dbacef81f42..cdc1aa0358d 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -987,7 +987,7 @@ determine_specialization (template_id, decl, targs_out, /* Check for baselinks. */ if (BASELINK_P (fns)) - fns = TREE_VALUE (fns); + fns = BASELINK_FUNCTIONS (fns); if (!is_overloaded_fn (fns)) { @@ -5150,13 +5150,7 @@ instantiate_class_template (type) /* Now call xref_basetypes to set up all the base-class information. */ - xref_basetypes (TREE_CODE (pattern) == RECORD_TYPE - ? (CLASSTYPE_DECLARED_CLASS (pattern) - ? class_type_node : record_type_node) - : union_type_node, - DECL_NAME (TYPE_NAME (pattern)), - type, - base_list); + xref_basetypes (type, base_list); } /* Now that our base classes are set up, enter the scope of the diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 0f671aee2de..576d931b171 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1063,6 +1063,15 @@ finish_named_return_value (return_id, init) DECL_UNINLINABLE (current_function_decl) = 1; } +/* Begin processing a mem-initializer-list. */ + +void +begin_mem_initializers () +{ + if (! DECL_CONSTRUCTOR_P (current_function_decl)) + error ("only constructors take base initializers"); +} + /* The INIT_LIST is a list of mem-initializers, in the order they were written by the user. The TREE_VALUE of each node is a list of initializers for a particular subobject. The TREE_PURPOSE is a diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 9c146960b08..1fca146d4b1 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -948,7 +948,7 @@ is_overloaded_fn (x) if (TREE_CODE (x) == OFFSET_REF) x = TREE_OPERAND (x, 1); if (BASELINK_P (x)) - x = TREE_VALUE (x); + x = BASELINK_FUNCTIONS (x); return (TREE_CODE (x) == FUNCTION_DECL || TREE_CODE (x) == TEMPLATE_ID_EXPR || DECL_FUNCTION_TEMPLATE_P (x) @@ -963,12 +963,26 @@ really_overloaded_fn (x) if (TREE_CODE (x) == OFFSET_REF) x = TREE_OPERAND (x, 1); if (BASELINK_P (x)) - x = TREE_VALUE (x); + x = BASELINK_FUNCTIONS (x); return (TREE_CODE (x) == OVERLOAD && (TREE_CHAIN (x) != NULL_TREE || DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (x)))); } +/* Return the OVERLOAD or FUNCTION_DECL inside FNS. FNS can be an + OVERLOAD, FUNCTION_DECL, TEMPLATE_ID_EXPR, or baselink. */ + +tree +get_overloaded_fn (fns) + tree fns; +{ + if (TREE_CODE (fns) == TEMPLATE_ID_EXPR) + fns = TREE_OPERAND (fns, 0); + if (BASELINK_P (fns)) + fns = BASELINK_FUNCTIONS (fns); + return fns; +} + tree get_first_fn (from) tree from; @@ -976,7 +990,7 @@ get_first_fn (from) my_friendly_assert (is_overloaded_fn (from), 9); /* A baselink is also considered an overloaded function. */ if (BASELINK_P (from)) - from = TREE_VALUE (from); + from = BASELINK_FUNCTIONS (from); return OVL_CURRENT (from); }