public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* RFA: PATCH to add chain lookup by index
@ 2009-09-10 21:09 Jason Merrill
  2009-09-10 21:14 ` Richard Henderson
  0 siblings, 1 reply; 6+ messages in thread
From: Jason Merrill @ 2009-09-10 21:09 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 189 bytes --]

It seems odd to me that this function didn't already exist, am I missing 
something?  I want to use it for a C++ patch which will follow once this 
is in.

Tested x86_64-pc-linux-gnu.  OK?

[-- Attachment #2: chain-index.patch --]
[-- Type: text/x-patch, Size: 1092 bytes --]

commit c72cdc4d6d659121d8171f5f2bedd3c27b7a54e0
Author: Jason Merrill <jason@redhat.com>
Date:   Thu Sep 10 17:05:45 2009 -0400

    	* tree.c (chain_index): New fn.
    	* tree.h: Declare it.

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
diff --git a/gcc/tree.h b/gcc/tree.h
index 9881090..7b431af 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -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);

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFA: PATCH to add chain lookup by index
  2009-09-10 21:09 RFA: PATCH to add chain lookup by index Jason Merrill
@ 2009-09-10 21:14 ` Richard Henderson
  2009-09-10 21:20   ` Jason Merrill
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Henderson @ 2009-09-10 21:14 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches List

On 09/10/2009 02:09 PM, Jason Merrill wrote:
> It seems odd to me that this function didn't already exist, am I missing
> something?

I would have hoped that anything index based would
be using vectors instead of chains...


r~

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFA: PATCH to add chain lookup by index
  2009-09-10 21:14 ` Richard Henderson
@ 2009-09-10 21:20   ` Jason Merrill
  2009-09-10 22:23     ` Richard Henderson
  0 siblings, 1 reply; 6+ messages in thread
From: Jason Merrill @ 2009-09-10 21:20 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches List

On 09/10/2009 05:14 PM, Richard Henderson wrote:
> On 09/10/2009 02:09 PM, Jason Merrill wrote:
>> It seems odd to me that this function didn't already exist, am I missing
>> something?
>
> I would have hoped that anything index based would
> be using vectors instead of chains...

Currently the argument types for a FUNCTION_TYPE are represented as a 
list; for diagnostic purposes, I want to look up the corresponding type 
in the original template.

Jason

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFA: PATCH to add chain lookup by index
  2009-09-10 22:23     ` Richard Henderson
@ 2009-09-10 21:36       ` Jason Merrill
  2009-09-10 21:37         ` Richard Henderson
  0 siblings, 1 reply; 6+ messages in thread
From: Jason Merrill @ 2009-09-10 21:36 UTC (permalink / raw)
  To: Richard Henderson; +Cc: gcc-patches List

On 09/10/2009 05:35 PM, Richard Henderson wrote:
> On 09/10/2009 02:20 PM, Jason Merrill wrote:
>> Currently the argument types for a FUNCTION_TYPE are represented as a
>> list; for diagnostic purposes, I want to look up the corresponding type
>> in the original template.
>
> Ah. Well don't let me stand in your way.

So the patch is OK?

Jason

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFA: PATCH to add chain lookup by index
  2009-09-10 21:36       ` Jason Merrill
@ 2009-09-10 21:37         ` Richard Henderson
  0 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2009-09-10 21:37 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches List

On 09/10/2009 02:36 PM, Jason Merrill wrote:
> On 09/10/2009 05:35 PM, Richard Henderson wrote:
>> On 09/10/2009 02:20 PM, Jason Merrill wrote:
>>> Currently the argument types for a FUNCTION_TYPE are represented as a
>>> list; for diagnostic purposes, I want to look up the corresponding type
>>> in the original template.
>>
>> Ah. Well don't let me stand in your way.
>
> So the patch is OK?

Yes.


r~

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: RFA: PATCH to add chain lookup by index
  2009-09-10 21:20   ` Jason Merrill
@ 2009-09-10 22:23     ` Richard Henderson
  2009-09-10 21:36       ` Jason Merrill
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Henderson @ 2009-09-10 22:23 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches List

On 09/10/2009 02:20 PM, Jason Merrill wrote:
> Currently the argument types for a FUNCTION_TYPE are represented as a
> list; for diagnostic purposes, I want to look up the corresponding type
> in the original template.

Ah.  Well don't let me stand in your way.


r~

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-09-10 22:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-10 21:09 RFA: PATCH to add chain lookup by index Jason Merrill
2009-09-10 21:14 ` Richard Henderson
2009-09-10 21:20   ` Jason Merrill
2009-09-10 22:23     ` Richard Henderson
2009-09-10 21:36       ` Jason Merrill
2009-09-10 21:37         ` Richard Henderson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).