aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1998-10-29 20:46:55 +0000
committerJason Merrill <jason@gcc.gnu.org>1998-10-29 15:46:55 -0500
commit72c4a2a6fbab94257014f5f2cb7df9a8d0bb3d10 (patch)
tree5c42483518ada75c2327e7fb30ff94f88a2cd184 /gcc
parentba4f4e5d1cc4bf5dc19167c5fd2179e100cdf5f0 (diff)
downloadgcc-72c4a2a6fbab94257014f5f2cb7df9a8d0bb3d10.zip
gcc-72c4a2a6fbab94257014f5f2cb7df9a8d0bb3d10.tar.gz
gcc-72c4a2a6fbab94257014f5f2cb7df9a8d0bb3d10.tar.bz2
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
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog10
-rw-r--r--gcc/cp/cp-tree.h7
-rw-r--r--gcc/cp/search.c85
3 files changed, 56 insertions, 46 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index fd5706b..d90e22d 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,7 +1,17 @@
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>
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 9c46c90..7c41273 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -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.
@@ -1036,6 +1036,9 @@ struct lang_type
#define BINFO_PUSHDECLS_MARKED(NODE) 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)
+
+/* Used by various search routines. */
+#define IDENTIFIER_MARKED(NODE) TREE_LANG_FLAG_0 (NODE)
/* Accessor macros for the vfield slots in structures. */
@@ -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 */
diff --git a/gcc/cp/search.c b/gcc/cp/search.c
index 26599f1..71298ed 100644
--- a/gcc/cp/search.c
+++ b/gcc/cp/search.c
@@ -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,
- tree_has_any_destructor_p);
- return tmp;
+ return breadth_first_search (binfo,
+ get_virtual_destructor,
+ tree_has_any_destructor_p);
}
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;
- 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
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;
}