Commit bf3428d0 by Mark Mitchell Committed by Mark Mitchell

cp-tree.h (finish_mem_initializers): Declare.

	* cp-tree.h (finish_mem_initializers): Declare.
	(count_trees): Likewise.
	* parse.y (base_init): Use finish_mem_initializers.
	* semantics.c (finish_mem_initializers): New function.

	* tree.c (count_trees_r): Prototype.  Use DATA parameter to store
	the number of trees.
	(n_trees): Remove.
	(count_trees): Don't use it.

From-SVN: r34574
parent 22c40c28
2000-06-16 Mark Mitchell <mark@codesourcery.com>
* cp-tree.h (finish_mem_initializers): Declare.
(count_trees): Likewise.
* parse.y (base_init): Use finish_mem_initializers.
* semantics.c (finish_mem_initializers): New function.
* tree.c (count_trees_r): Prototype. Use DATA parameter to store
the number of trees.
(n_trees): Remove.
(count_trees): Don't use it.
2000-06-15 Jason Merrill <jason@redhat.com>
* tree.c (count_trees): New debugging function.
......
......@@ -4479,6 +4479,7 @@ extern void prep_stmt PARAMS ((tree));
extern tree add_scope_stmt PARAMS ((int, int));
extern void do_pushlevel PARAMS ((void));
extern tree do_poplevel PARAMS ((void));
extern void finish_mem_initializers PARAMS ((tree));
/* in spew.c */
extern void init_spew PARAMS ((void));
......@@ -4556,6 +4557,7 @@ extern void remap_save_expr PARAMS ((tree *, splay_tree, tre
cp_build_qualified_type_real ((TYPE), (QUALS), /*complain=*/1)
extern tree build_shared_int_cst PARAMS ((int));
extern special_function_kind special_function_p PARAMS ((tree));
extern int count_trees PARAMS ((tree));
/* in typeck.c */
extern int string_conv_p PARAMS ((tree, tree, int));
......
......@@ -854,40 +854,10 @@ return_init:
base_init:
':' .set_base_init member_init_list
{
tree member_init_list = NULL_TREE;
tree base_init_list = NULL_TREE;
tree init;
tree next;
int seen_member_init_p;
if ($3.new_type_flag == 0)
error ("no base or member initializers given following ':'");
seen_member_init_p = 0;
for (init = $3.t; init; init = next)
{
next = TREE_CHAIN (init);
if (TREE_CODE (TREE_PURPOSE (init)) == FIELD_DECL)
{
TREE_CHAIN (init) = member_init_list;
member_init_list = init;
seen_member_init_p = 1;
}
else
{
if (warn_reorder && seen_member_init_p)
{
cp_warning ("base initializer for `%T'",
TREE_PURPOSE (init));
warning (" will be re-ordered to precede member initializations");
}
TREE_CHAIN (init) = base_init_list;
base_init_list = init;
}
}
setup_vtbl_ptr (member_init_list, base_init_list);
finish_mem_initializers ($3.t);
}
;
......
......@@ -1230,6 +1230,65 @@ finish_named_return_value (return_id, init)
DECL_UNINLINABLE (current_function_decl) = 1;
}
/* 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
FIELD_DECL is the initializer is for a non-static data member, and
a class type if the initializer is for a base class. */
void
finish_mem_initializers (init_list)
tree init_list;
{
tree member_init_list;
tree base_init_list;
tree last_base_warned_about;
tree next;
tree init;
member_init_list = NULL_TREE;
base_init_list = NULL_TREE;
last_base_warned_about = NULL_TREE;
for (init = init_list; init; init = next)
{
next = TREE_CHAIN (init);
if (TREE_CODE (TREE_PURPOSE (init)) == FIELD_DECL)
{
TREE_CHAIN (init) = member_init_list;
member_init_list = init;
/* We're running through the initializers from right to left
as we process them here. So, if we see a data member
initializer after we see a base initializer, that
actually means that the base initializer preceeded the
data member initializer. */
if (warn_reorder && last_base_warned_about != base_init_list)
{
tree base;
for (base = base_init_list;
base != last_base_warned_about;
base = TREE_CHAIN (base))
{
cp_warning ("base initializer for `%T'",
TREE_PURPOSE (base));
warning (" will be re-ordered to precede member initializations");
}
last_base_warned_about = base_init_list;
}
}
else
{
TREE_CHAIN (init) = base_init_list;
base_init_list = init;
}
}
setup_vtbl_ptr (member_init_list, base_init_list);
}
/* Cache the value of this class's main virtual function table pointer
in a register variable. This will save one indirection if a
more than one virtual function call is made this function. */
......
......@@ -47,6 +47,7 @@ static tree mark_local_for_remap_r PARAMS ((tree *, int *, void *));
static tree cp_unsave_r PARAMS ((tree *, int *, void *));
static void cp_unsave PARAMS ((tree *));
static tree build_target_expr PARAMS ((tree, tree));
static tree count_trees_r PARAMS ((tree *, int *, void *));
/* If REF is an lvalue, returns the kind of lvalue that REF is.
Otherwise, returns clk_none. If TREAT_CLASS_RVALUES_AS_LVALUES is
......@@ -1396,15 +1397,15 @@ walk_tree (tp, func, data)
#undef WALK_SUBTREE
}
int n_trees;
/* Called from count_trees via walk_tree. */
static tree
count_trees_r (tp, walk_subtrees, data)
tree *tp ATTRIBUTE_UNUSED;
int *walk_subtrees ATTRIBUTE_UNUSED;
void *data ATTRIBUTE_UNUSED;
void *data;
{
++n_trees;
++ *((int*) data);
return NULL_TREE;
}
......@@ -1415,8 +1416,8 @@ int
count_trees (t)
tree t;
{
n_trees = 0;
walk_tree (&t, count_trees_r, NULL);
int n_trees = 0;
walk_tree (&t, count_trees_r, &n_trees);
return n_trees;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment