This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Question on tree-walking and mutually-recursive types
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: pinskia at physics dot uc dot edu
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 28 Jun 04 23:22:29 EDT
- Subject: Re: Question on tree-walking and mutually-recursive types
Yes walk using a hashtable saying you already walked the tree.
walk_tree_without_duplicates is what you want.
Well, I figured out a way to perhaps keep the cost under control but still
handle the pathalogical case. I used what was below and it works,
but YUCK!
Any other ideas or should I go ahead with this kludge?
*** tree-inline.c 26 Jun 2004 21:11:11 -0000 1.116
--- tree-inline.c 29 Jun 2004 03:17:28 -0000
*************** walk_tree (tree *tp, walk_tree_fn func,
*** 2206,2209 ****
--- 2206,2231 ----
case POINTER_TYPE:
case REFERENCE_TYPE:
+ /* We have to worry about mutually recursive pointers. These can't
+ be written in C. They can in Ada. It's pathlogical, but
+ there's an ACATS test (c38102a) that checks it. Deal with this
+ by checking if we're pointing to another pointer, that one
+ points to another pointer, that one does too, and we have no htab.
+ If so, get a hash table. We check three levels deep to avoid
+ the cost of the hash table if we don't need one. */
+ if (POINTER_TYPE_P (TREE_TYPE (*tp))
+ && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (*tp)))
+ && POINTER_TYPE_P (TREE_TYPE (TREE_TYPE (TREE_TYPE (*tp))))
+ && !htab)
+ {
+ result = walk_tree_without_duplicates (&TREE_TYPE (*tp),
+ func, data);
+ if (result)
+ return result;
+
+ break;
+ }
+
+ /* ... fall through ... */
+
case COMPLEX_TYPE:
WALK_SUBTREE_TAIL (TREE_TYPE (*tp));