C++ PATCH: More cleanups
Mark Mitchell
mark@codesourcery.com
Tue Jun 25 08:43:00 GMT 2002
More cleanups designed to get the new parser a little closer to
compiling again...
Tested on i686-pc-linux-gnu, installed on the mainline.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
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.
Index: call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.320
diff -c -p -r1.320 call.c
*** call.c 4 Jun 2002 07:09:55 -0000 1.320
--- call.c 25 Jun 2002 15:34:26 -0000
*************** build_op_delete_call (code, addr, size,
*** 3698,3704 ****
/* Go through the `operator delete' functions looking for one
with a matching type. */
! for (fn = BASELINK_P (fns) ? TREE_VALUE (fns) : fns;
fn;
fn = OVL_NEXT (fn))
{
--- 3698,3704 ----
/* Go through the `operator delete' functions looking for one
with a matching type. */
! for (fn = BASELINK_P (fns) ? BASELINK_FUNCTIONS (fns) : fns;
fn;
fn = OVL_NEXT (fn))
{
Index: class.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/class.c,v
retrieving revision 1.453
diff -c -p -r1.453 class.c
*** class.c 24 Jun 2002 19:18:40 -0000 1.453
--- class.c 25 Jun 2002 15:34:28 -0000
*************** handle_using_decl (using_decl, t)
*** 1235,1241 ****
if (BASELINK_P (fdecl))
/* Ignore base type this came from. */
! fdecl = TREE_VALUE (fdecl);
old_value = IDENTIFIER_CLASS_VALUE (name);
if (old_value)
--- 1235,1241 ----
if (BASELINK_P (fdecl))
/* Ignore base type this came from. */
! fdecl = BASELINK_FUNCTIONS (fdecl);
old_value = IDENTIFIER_CLASS_VALUE (name);
if (old_value)
*************** instantiate_type (lhstype, rhs, flags)
*** 6139,6145 ****
case OFFSET_REF:
rhs = TREE_OPERAND (rhs, 1);
if (BASELINK_P (rhs))
! return instantiate_type (lhstype, TREE_VALUE (rhs),
flags | allow_ptrmem);
/* This can happen if we are forming a pointer-to-member for a
--- 6139,6145 ----
case OFFSET_REF:
rhs = TREE_OPERAND (rhs, 1);
if (BASELINK_P (rhs))
! return instantiate_type (lhstype, BASELINK_FUNCTIONS (rhs),
flags | allow_ptrmem);
/* This can happen if we are forming a pointer-to-member for a
*************** instantiate_type (lhstype, rhs, flags)
*** 6175,6181 ****
/* Now we should have a baselink. */
my_friendly_assert (BASELINK_P (rhs), 990412);
! return instantiate_type (lhstype, TREE_VALUE (rhs), flags);
case CALL_EXPR:
/* This is too hard for now. */
--- 6175,6181 ----
/* Now we should have a baselink. */
my_friendly_assert (BASELINK_P (rhs), 990412);
! return instantiate_type (lhstype, BASELINK_FUNCTIONS (rhs), flags);
case CALL_EXPR:
/* This is too hard for now. */
Index: cp-tree.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/cp-tree.h,v
retrieving revision 1.721
diff -c -p -r1.721 cp-tree.h
*** cp-tree.h 24 Jun 2002 19:18:41 -0000 1.721
--- cp-tree.h 25 Jun 2002 15:34:29 -0000
*************** struct tree_overload GTY(())
*** 385,390 ****
--- 385,394 ----
(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 int grok_ctor_properties PARAMS
*** 3854,3860 ****
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 tree start_enum PARAMS ((tree));
extern void finish_enum PARAMS ((tree));
extern void build_enumerator PARAMS ((tree, tree, tree));
--- 3858,3864 ----
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));
extern tree start_enum PARAMS ((tree));
extern void finish_enum PARAMS ((tree));
extern void build_enumerator PARAMS ((tree, tree, tree));
*************** extern void expand_body
*** 4306,4311 ****
--- 4310,4316 ----
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 make_binfo PARAMS ((tree,
*** 4355,4360 ****
--- 4360,4366 ----
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));
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.913
diff -c -p -r1.913 decl.c
*** decl.c 24 Jun 2002 19:18:41 -0000 1.913
--- decl.c 25 Jun 2002 15:34:32 -0000
*************** xref_tag_from_type (old, id, globalize)
*** 12983,12991 ****
struct, or union. */
void
! xref_basetypes (code_type_node, name, ref, binfo)
! tree code_type_node;
! tree name ATTRIBUTE_UNUSED;
tree ref;
tree binfo;
{
--- 12983,12989 ----
struct, or union. */
void
! xref_basetypes (ref, binfo)
tree ref;
tree binfo;
{
*************** xref_basetypes (code_type_node, name, re
*** 12997,13016 ****
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)
{
error ("derived union `%T' invalid", ref);
return;
}
len = list_length (binfo);
--- 12995,13007 ----
int i, len;
enum tag_types tag_code;
! 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);
Index: error.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/error.c,v
retrieving revision 1.180
diff -c -p -r1.180 error.c
*** error.c 6 Jun 2002 03:20:10 -0000 1.180
--- error.c 25 Jun 2002 15:34:32 -0000
*************** dump_expr (t, flags)
*** 1882,1888 ****
/* 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);
else
dump_decl (t, flags);
}
--- 1882,1889 ----
/* A::f */
dump_expr (t, flags | TFF_EXPR_IN_PARENS);
else if (BASELINK_P (t))
! dump_expr (OVL_CURRENT (BASELINK_FUNCTIONS (t)),
! flags | TFF_EXPR_IN_PARENS);
else
dump_decl (t, flags);
}
Index: init.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/init.c,v
retrieving revision 1.281
diff -c -p -r1.281 init.c
*** init.c 21 May 2002 17:26:18 -0000 1.281
--- init.c 25 Jun 2002 15:34:33 -0000
*************** build_offset_ref (type, name)
*** 1671,1677 ****
{
/* Go from the TREE_BASELINK to the member function info. */
tree fnfields = member;
! t = TREE_VALUE (fnfields);
if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR)
{
--- 1671,1677 ----
{
/* Go from the TREE_BASELINK to the member function info. */
tree fnfields = member;
! t = BASELINK_FUNCTIONS (fnfields);
if (TREE_CODE (orig_name) == TEMPLATE_ID_EXPR)
{
Index: parse.y
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/parse.y,v
retrieving revision 1.265
diff -c -p -r1.265 parse.y
*** parse.y 24 Jun 2002 19:18:43 -0000 1.265
--- parse.y 25 Jun 2002 15:34:34 -0000
*************** return_init:
*** 945,958 ****
;
base_init:
! ':' member_init_list
{
! if (! DECL_CONSTRUCTOR_P (current_function_decl))
! error ("only constructors take base initializers");
! else if ($2.new_type_flag == 0)
error ("no base or member initializers given following ':'");
!
! finish_mem_initializers ($2.t);
}
;
--- 945,955 ----
;
base_init:
! ':' { begin_mem_initializers (); } member_init_list
{
! if ($3.new_type_flag == 0)
error ("no base or member initializers given following ':'");
! finish_mem_initializers ($3.t);
}
;
*************** structsp:
*** 2334,2340 ****
a TYPENAME_TYPE with a type. */
type = TREE_TYPE (type);
maybe_process_partial_specialization (type);
! xref_basetypes (current_aggr, $1.t, type, $2);
}
$1.t = begin_class_definition (TREE_TYPE ($1.t));
check_class_key (current_aggr, $1.t);
--- 2331,2337 ----
a TYPENAME_TYPE with a type. */
type = TREE_TYPE (type);
maybe_process_partial_specialization (type);
! xref_basetypes (type, $2);
}
$1.t = begin_class_definition (TREE_TYPE ($1.t));
check_class_key (current_aggr, $1.t);
Index: pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.593
diff -c -p -r1.593 pt.c
*** pt.c 20 Jun 2002 14:44:37 -0000 1.593
--- pt.c 25 Jun 2002 15:34:36 -0000
*************** determine_specialization (template_id, d
*** 987,993 ****
/* Check for baselinks. */
if (BASELINK_P (fns))
! fns = TREE_VALUE (fns);
if (!is_overloaded_fn (fns))
{
--- 987,993 ----
/* Check for baselinks. */
if (BASELINK_P (fns))
! fns = BASELINK_FUNCTIONS (fns);
if (!is_overloaded_fn (fns))
{
*************** instantiate_class_template (type)
*** 5150,5162 ****
/* 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);
}
/* Now that our base classes are set up, enter the scope of the
--- 5150,5156 ----
/* Now call xref_basetypes to set up all the base-class
information. */
! xref_basetypes (type, base_list);
}
/* Now that our base classes are set up, enter the scope of the
Index: semantics.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/semantics.c,v
retrieving revision 1.265
diff -c -p -r1.265 semantics.c
*** semantics.c 24 Jun 2002 19:18:43 -0000 1.265
--- semantics.c 25 Jun 2002 15:34:37 -0000
*************** finish_named_return_value (return_id, in
*** 1063,1068 ****
--- 1063,1077 ----
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
Index: tree.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/tree.c,v
retrieving revision 1.286
diff -c -p -r1.286 tree.c
*** tree.c 17 Jun 2002 00:26:55 -0000 1.286
--- tree.c 25 Jun 2002 15:34:37 -0000
*************** is_overloaded_fn (x)
*** 948,954 ****
if (TREE_CODE (x) == OFFSET_REF)
x = TREE_OPERAND (x, 1);
if (BASELINK_P (x))
! x = TREE_VALUE (x);
return (TREE_CODE (x) == FUNCTION_DECL
|| TREE_CODE (x) == TEMPLATE_ID_EXPR
|| DECL_FUNCTION_TEMPLATE_P (x)
--- 948,954 ----
if (TREE_CODE (x) == OFFSET_REF)
x = TREE_OPERAND (x, 1);
if (BASELINK_P (x))
! x = BASELINK_FUNCTIONS (x);
return (TREE_CODE (x) == FUNCTION_DECL
|| TREE_CODE (x) == TEMPLATE_ID_EXPR
|| DECL_FUNCTION_TEMPLATE_P (x)
*************** really_overloaded_fn (x)
*** 963,974 ****
if (TREE_CODE (x) == OFFSET_REF)
x = TREE_OPERAND (x, 1);
if (BASELINK_P (x))
! x = TREE_VALUE (x);
return (TREE_CODE (x) == OVERLOAD
&& (TREE_CHAIN (x) != NULL_TREE
|| DECL_FUNCTION_TEMPLATE_P (OVL_FUNCTION (x))));
}
tree
get_first_fn (from)
tree from;
--- 963,988 ----
if (TREE_CODE (x) == OFFSET_REF)
x = TREE_OPERAND (x, 1);
if (BASELINK_P (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;
*************** get_first_fn (from)
*** 976,982 ****
my_friendly_assert (is_overloaded_fn (from), 9);
/* A baselink is also considered an overloaded function. */
if (BASELINK_P (from))
! from = TREE_VALUE (from);
return OVL_CURRENT (from);
}
--- 990,996 ----
my_friendly_assert (is_overloaded_fn (from), 9);
/* A baselink is also considered an overloaded function. */
if (BASELINK_P (from))
! from = BASELINK_FUNCTIONS (from);
return OVL_CURRENT (from);
}
More information about the Gcc-patches
mailing list