diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-09-10 21:40:06 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-09-10 21:40:06 +0000 |
commit | 7616de9318924405c384cf6a2d451abbb42f521c (patch) | |
tree | 97fe29f2f32f424cedb3831187475be5ea383ec8 /gcc/tree.c | |
parent | 15ca386589c818417731fb096d1d65048760976b (diff) | |
download | gcc-7616de9318924405c384cf6a2d451abbb42f521c.tar.gz |
* tree.c (chain_index): New fn.
* tree.h: Declare it.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151618 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/tree.c')
-rw-r--r-- | gcc/tree.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/gcc/tree.c b/gcc/tree.c index 2f0e03c8e22..27ab46cdd93 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 |