This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Question on tree-walking and mutually-recursive types


walk_tree walks the type of all variables in a BIND_EXPR.  And walking
a POINTER_TYPE walks the type it points to.

But it's possible for a pointer type X to point to a pointer type Y, which
points back to X.  I don't think you can express this in C, but you can in Ada:

procedure tpself is
  type Tp1;
  type tp2 is access Tp1;
  type Tp1 is access Tp2;
  X: Tp1;
begin
   null;
end tpself;

You may ask why somebody would want to write something like that and it's a
good question, but the general rule for Ada is that if you *can* write
something, you can be sure that an ACATS test *will* try it.  In this case
it's c38102a, part of which is explicitly written just to test this case!

We go into an infinite loop here (not recursion because of WALK_SUBTREE_TAIL).

It's tempting to not go into TREE_TYPE of a POINTER_TYPE in the tree walk,
but I found out the hard way last week that issuing certain error messages
for C++ templates depends on that walk being done.

Any suggestions how to deal with this?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]