diff options
author | Jason Merrill <jason@redhat.com> | 2009-09-10 17:40:06 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2009-09-10 17:40:06 -0400 |
commit | ad42ff1e07cf3a19669ba9d11a89a26d2eff99d4 (patch) | |
tree | 97fe29f2f32f424cedb3831187475be5ea383ec8 /gcc/tree.c | |
parent | 43dfd40c1d5934d5850dcfd2c9a1b9e856bf32a7 (diff) | |
download | gcc-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.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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 |