OSDN Git Service

* tree.c (chain_index): New fn.
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Sep 2009 21:40:06 +0000 (21:40 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 10 Sep 2009 21:40:06 +0000 (21:40 +0000)
* tree.h: Declare it.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151618 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree.c
gcc/tree.h

index e8eb477..c97ff8a 100644 (file)
@@ -1,3 +1,8 @@
+2009-09-10  Jason Merrill  <jason@redhat.com>
+
+       * tree.c (chain_index): New fn.
+       * tree.h: Declare it.
+
 2009-09-10  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
        * config/sol2-c.c (cmn_err_length_specs): Initialize
index 2f0e03c..27ab46c 100644 (file)
@@ -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
index 9881090..7b431af 100644 (file)
@@ -3914,6 +3914,7 @@ extern bool range_in_array_bounds_p (tree);
 
 extern tree value_member (tree, tree);
 extern tree purpose_member (const_tree, tree);
+extern tree chain_index (int, tree);
 
 extern int attribute_list_equal (const_tree, const_tree);
 extern int attribute_list_contained (const_tree, const_tree);