Do you have ideas about how to improve the naming? Perhaps change
TYPE_ANONYMOUS_P to TYPE_NO_LINKAGE_NAME?
I haven't thought about changing names but TYPE_NO_LINKAGE_NAME
seems better than TYPE_ANONYMOUS_P.
Or perhaps TYPE_UNNAMED_P.
TYPE_UNNAMED_P would work but it wouldn't be a replacement for
TYPE_ANONYMOUS_P.
It sounds like TYPE_ANONYMOUS_P is the right name and the problem
is that the value it returns isn't accurate until the full context
to which it applies has been seen.
I wonder if the right solution to this class of problems (which
are probably unavoidable in the front end as the tree is being
constructed), is to design an API that prevents using these
"unreliable" queries until they can return a reliable result.
With this approach, as each tree node is being constructed, its
"dynamic" type would reflect only the most specific entity that
has been determined so far (e.g., here, the type would be STRUCT
but not ANONYMOUS_STRUCT, with the latter "derived" from the
former). I suspect that implementing this model using C++
polymorphism would be far too big and slow to be practical but
it could be done via some lighter-weight mechanism that would
avoid these problems.
Martin