aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree.c
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2009-09-10 17:40:06 -0400
committerJason Merrill <jason@gcc.gnu.org>2009-09-10 17:40:06 -0400
commitad42ff1e07cf3a19669ba9d11a89a26d2eff99d4 (patch)
tree97fe29f2f32f424cedb3831187475be5ea383ec8 /gcc/tree.c
parent43dfd40c1d5934d5850dcfd2c9a1b9e856bf32a7 (diff)
downloadgcc-ad42ff1e07cf3a19669ba9d11a89a26d2eff99d4.zip
gcc-ad42ff1e07cf3a19669ba9d11a89a26d2eff99d4.tar.gz
gcc-ad42ff1e07cf3a19669ba9d11a89a26d2eff99d4.tar.bz2
tree.c (chain_index): New fn.
* tree.c (chain_index): New fn. * tree.h: Declare it. From-SVN: r151618
Diffstat (limited to 'gcc/tree.c')
-rw-r--r--gcc/tree.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c
index 2f0e03c..27ab46c 100644
--- a/gcc/tree.c
+++ b/gcc/tree.c
@@ -1905,6 +1905,17 @@ purpose_member (const_tree elem, tree list)
return NULL_TREE;
}
+/* Returns element number IDX (zero-origin) of chain CHAIN, or
+ NULL_TREE. */
+
+tree
+chain_index (int idx, tree chain)
+{
+ for (; chain && idx > 0; --idx)
+ chain = TREE_CHAIN (chain);
+ return chain;
+}
+
/* Return nonzero if ELEM is part of the chain CHAIN. */
int