summaryrefslogtreecommitdiff
path: root/gcc/pointer-set.c
diff options
context:
space:
mode:
authorpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>2004-12-21 21:20:02 +0000
committerpinskia <pinskia@138bc75d-0d04-0410-961f-82ee72b054a4>2004-12-21 21:20:02 +0000
commit675cc66a3a20c219eee05919bec5580f1b3c0c2c (patch)
tree26a2279877aa52f21fba4ae120751143f5815a44 /gcc/pointer-set.c
parentf4dc4c794dc64dda19ab8bf99fe9a9c964111ec8 (diff)
downloadgcc-675cc66a3a20c219eee05919bec5580f1b3c0c2c.tar.gz
2004-12-21 Andrew Pinski <pinskia@physics.uc.edu>
PR c++/18984 * pointer-set.c (pointer_set_contains): Add back. * pointer-set.h (pointer_set_contains): Add back. 2004-12-21 Andrew Pinski <pinskia@physics.uc.edu> PR c++/18984 * cp-gimplify.c (cp_genericize_r): Don't insert first but instead check to see if contains the pointer. Insert the statement before returning. 2004-12-21 Andrew Pinski <pinskia@physics.uc.edu> PR C++/18984 * g++.dg/eh/ctor3.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@92470 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/pointer-set.c')
-rw-r--r--gcc/pointer-set.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/gcc/pointer-set.c b/gcc/pointer-set.c
index 3f79cc2bfa7..266cccfef8a 100644
--- a/gcc/pointer-set.c
+++ b/gcc/pointer-set.c
@@ -90,6 +90,29 @@ void pointer_set_destroy (struct pointer_set_t *pset)
XDELETE (pset);
}
+/* Returns nonzero if PSET contains P. P must be nonnull.
+
+ Collisions are resolved by linear probing. */
+int
+pointer_set_contains (struct pointer_set_t *pset, void *p)
+{
+ size_t n = hash1 (p, pset->n_slots, pset->log_slots);
+
+ while (true)
+ {
+ if (pset->slots[n] == p)
+ return 1;
+ else if (pset->slots[n] == 0)
+ return 0;
+ else
+ {
+ ++n;
+ if (n == pset->n_slots)
+ n = 0;
+ }
+ }
+}
+
/* Subroutine of pointer_set_insert. Inserts P into an empty
element of SLOTS, an array of length N_SLOTS. Returns nonzero
if P was already present in N_SLOTS. */