* 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
+2002-06-25 Mark Mitchell <mark@codesourcery.com>
+
+ * 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 <mark@codesourcery.com>
* cp-tree.h (SCALAR_TYPE_P): New macro.
/* 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))
{
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)
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
/* 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. */
(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)
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));
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));
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));
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;
{
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
/* 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);
}
{
/* 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)
{
;
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);
}
;
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);
/* Check for baselinks. */
if (BASELINK_P (fns))
- fns = TREE_VALUE (fns);
+ fns = BASELINK_FUNCTIONS (fns);
if (!is_overloaded_fn (fns))
{
/* 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
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
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)
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;
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);
}