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