On Aug 30, 2010, at 5:33 PM, Benoit Belley wrote:
> I think that I’ll need a bit more explanation here. The infinite recursion
> occurs while traversing the instantiations of the class template definition
> and I do want to traverse these instantiations. That’s the whole point of my
> proposed change.
Yes, I understood that. My point is that you're visiting the instantiations
regardless of whether the current template declaration you're visiting is a
redeclaration or not. This creates two problems: first, you end up visiting
the instantiations multiple times if the template is redeclared; and second, if
the template is redeclared within itself (which can only be done with friend
declarations), you end up visiting it recursively, which blows up the stack.
The solution is to only visit implicit instantiations when you visit a pattern
definition.
template <class T> class A; // <- don't visit any instantiations here
class B { template <class T> friend class A; }; // <- or here
template <class T> class A { ... }; // <- okay to visit implicit
instantiations here
> By the way, here’s one more bit of information. The problem does not occur
> when the template is explicitly instantiated:
Yes, because your implementation of TraverseImplicitClassInstantiations ignores
explicit instantiations. So when you visit the explicit instantiation, you
visit its friend decl, whereupon you visit all the implicit instantiations,
which (as long as there are none) doesn't cause an infinite recursion because
you ignore the explicit instantiation.
Also, can you explain why you're not visiting the written type of explicit
specializations when your flag is set? That doesn't seem very general.
John.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits