Commit 72c4a2a6 by Jason Merrill Committed by Jason Merrill

cp-tree.h (IDENTIFIER_MARKED): New macro.

	* cp-tree.h (IDENTIFIER_MARKED): New macro.
	* search.c (lookup_conversions): Use breadth_first_search.
	(add_conversions): Avoid adding two conversions to the same type.
	(breadth_first_search): Work with base binfos, rather
	than binfos and base indices.
	(get_virtual_destructor): Adjust.
	(tree_has_any_destructor_p): Adjust.
	(get_matching_virtual): Adjust.
Fixes g++.other/conv4.C

From-SVN: r23433
parent ba4f4e5d
1998-10-29 Jason Merrill <jason@yorick.cygnus.com>
* cp-tree.h (IDENTIFIER_MARKED): New macro.
* search.c (lookup_conversions): Use breadth_first_search.
(add_conversions): Avoid adding two conversions to the same type.
(breadth_first_search): Work with base binfos, rather
than binfos and base indices.
(get_virtual_destructor): Adjust.
(tree_has_any_destructor_p): Adjust.
(get_matching_virtual): Adjust.
* pt.c (push_template_decl_real): Generalize check for incorrect
number of template parms.
(is_member_template_class): #if 0.
1998-10-29 Richard Henderson <rth@cygnus.com>
......
......@@ -32,7 +32,7 @@ Boston, MA 02111-1307, USA. */
DELETE_EXPR_USE_GLOBAL (in DELETE_EXPR).
LOOKUP_EXPR_GLOBAL (in LOOKUP_EXPR).
TREE_NEGATED_INT (in INTEGER_CST).
(TREE_MANGLED) (in IDENTIFIER_NODE) (commented-out).
IDENTIFIER_MARKED (used by search routines).
1: IDENTIFIER_VIRTUAL_P.
TI_PENDING_TEMPLATE_FLAG.
TEMPLATE_PARMS_FOR_INLINE.
......@@ -1037,6 +1037,9 @@ struct lang_type
#define SET_BINFO_PUSHDECLS_MARKED(NODE) SET_BINFO_VTABLE_PATH_MARKED (NODE)
#define CLEAR_BINFO_PUSHDECLS_MARKED(NODE) CLEAR_BINFO_VTABLE_PATH_MARKED (NODE)
/* Used by various search routines. */
#define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_0 (NODE)
/* Accessor macros for the vfield slots in structures. */
/* Get the assoc info that caused this vfield to exist. */
......@@ -1398,7 +1401,7 @@ struct lang_decl
/* Nonzero in IDENTIFIER_NODE means that this name is not the name the user
gave; it's a DECL_NESTED_TYPENAME. Someone may want to set this on
mangled function names, too, but it isn't currently. */
#define TREE_MANGLED(NODE) (TREE_LANG_FLAG_0 (NODE))
#define TREE_MANGLED(NODE) (FOO)
#endif
#if 0 /* UNUSED */
......
......@@ -116,17 +116,17 @@ static void dfs_get_vbase_types PROTO((tree));
static void dfs_pushdecls PROTO((tree));
static void dfs_compress_decls PROTO((tree));
static void dfs_unuse_fields PROTO((tree));
static void add_conversions PROTO((tree));
static tree add_conversions PROTO((tree));
static tree get_virtuals_named_this PROTO((tree));
static tree get_virtual_destructor PROTO((tree, int));
static int tree_has_any_destructor_p PROTO((tree, int));
static tree get_virtual_destructor PROTO((tree));
static int tree_has_any_destructor_p PROTO((tree));
static int covariant_return_p PROTO((tree, tree));
static struct search_level *push_search_level
PROTO((struct stack_level *, struct obstack *));
static struct search_level *pop_search_level
PROTO((struct stack_level *));
static HOST_WIDE_INT breadth_first_search
PROTO((tree, int (*) (tree, int), int (*) (tree, int)));
static tree breadth_first_search
PROTO((tree, tree (*) (tree), int (*) (tree)));
static tree vbase_types;
static tree vbase_decl_ptr_intermediate, vbase_decl_ptr;
......@@ -1605,17 +1605,21 @@ lookup_member (xbasetype, name, protect, want_type)
QFN, if non-NULL, is a predicate dictating whether the type should
even be queued. */
static HOST_WIDE_INT
static tree
breadth_first_search (binfo, testfn, qfn)
tree binfo;
int (*testfn) PROTO((tree, int));
int (*qfn) PROTO((tree, int));
tree (*testfn) PROTO((tree));
int (*qfn) PROTO((tree));
{
int head = 0, tail = 0;
int rval = 0;
tree rval = NULL_TREE;
search_stack = push_search_level (search_stack, &search_obstack);
SET_BINFO_MARKED (binfo);
obstack_ptr_grow (&search_obstack, binfo);
++tail;
while (1)
{
tree binfos = BINFO_BASETYPES (binfo);
......@@ -1628,12 +1632,11 @@ breadth_first_search (binfo, testfn, qfn)
tree base_binfo = TREE_VEC_ELT (binfos, i);
if (BINFO_MARKED (base_binfo) == 0
&& (qfn == 0 || (*qfn) (binfo, i)))
&& (qfn == 0 || (*qfn) (base_binfo)))
{
SET_BINFO_MARKED (base_binfo);
obstack_ptr_grow (&search_obstack, binfo);
obstack_ptr_grow (&search_obstack, (HOST_WIDE_INT) i);
tail += 2;
obstack_ptr_grow (&search_obstack, base_binfo);
++tail;
if (tail >= search_stack->limit)
my_friendly_abort (100);
}
......@@ -1646,10 +1649,8 @@ breadth_first_search (binfo, testfn, qfn)
}
binfo = search_stack->first[head++];
i = (HOST_WIDE_INT) search_stack->first[head++];
if ((rval = (*testfn) (binfo, i)))
if ((rval = (*testfn) (binfo)))
break;
binfo = BINFO_BASETYPE (binfo, i);
}
{
tree *tp = search_stack->first;
......@@ -1657,8 +1658,7 @@ breadth_first_search (binfo, testfn, qfn)
while (tp < search_tail)
{
tree binfo = *tp++;
int i = (HOST_WIDE_INT)(*tp++);
CLEAR_BINFO_MARKED (BINFO_BASETYPE (binfo, i));
CLEAR_BINFO_MARKED (binfo);
}
}
......@@ -1667,7 +1667,7 @@ breadth_first_search (binfo, testfn, qfn)
}
/* Functions to use in breadth first searches. */
typedef int (*pfi) PROTO((tree, int));
typedef tree (*pfi) PROTO((tree));
static tree declarator;
......@@ -1698,13 +1698,10 @@ get_virtuals_named_this (binfo)
}
static tree
get_virtual_destructor (binfo, i)
get_virtual_destructor (binfo)
tree binfo;
int i;
{
tree type = BINFO_TYPE (binfo);
if (i >= 0)
type = BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), i));
if (TYPE_HAS_DESTRUCTOR (type)
&& DECL_VINDEX (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), 1)))
return TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), 1);
......@@ -1712,13 +1709,10 @@ get_virtual_destructor (binfo, i)
}
static int
tree_has_any_destructor_p (binfo, i)
tree_has_any_destructor_p (binfo)
tree binfo;
int i;
{
tree type = BINFO_TYPE (binfo);
if (i >= 0)
type = BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), i));
return TYPE_NEEDS_DESTRUCTOR (type);
}
......@@ -1803,16 +1797,9 @@ get_matching_virtual (binfo, fndecl, dtorp)
of TYPE, so we must perform first ply of search here. */
if (dtorp)
{
if (tree_has_any_destructor_p (binfo, -1))
tmp = get_virtual_destructor (binfo, -1);
if (tmp)
return tmp;
tmp = (tree) breadth_first_search (binfo,
(pfi) get_virtual_destructor,
return breadth_first_search (binfo,
get_virtual_destructor,
tree_has_any_destructor_p);
return tmp;
}
else
{
......@@ -3284,7 +3271,7 @@ reinit_search_statistics ()
#define scratch_tree_cons expr_tree_cons
static tree conversions;
static void
static tree
add_conversions (binfo)
tree binfo;
{
......@@ -3297,21 +3284,31 @@ add_conversions (binfo)
if (!tmp || ! DECL_CONV_FN_P (OVL_CURRENT (tmp)))
break;
/* Make sure we don't already have this conversion. */
if (! IDENTIFIER_MARKED (DECL_NAME (tmp)))
{
conversions = scratch_tree_cons (binfo, tmp, conversions);
IDENTIFIER_MARKED (DECL_NAME (tmp)) = 1;
}
SET_BINFO_MARKED (binfo);
}
return NULL_TREE;
}
tree
lookup_conversions (type)
tree type;
{
tree t;
conversions = NULL_TREE;
if (TYPE_SIZE (type))
{
dfs_walk (TYPE_BINFO (type), add_conversions, unmarkedp);
dfs_walk (TYPE_BINFO (type), dfs_unmark, markedp);
}
breadth_first_search (TYPE_BINFO (type), add_conversions, 0);
for (t = conversions; t; t = TREE_CHAIN (t))
IDENTIFIER_MARKED (DECL_NAME (TREE_VALUE (t))) = 0;
return conversions;
}
......
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