Hi Jonathan,
Jonathan Wakely <[email protected]> writes:
> I don't know if GCC keeps the information you want, but according to
> the language rules there is no hierarchy. There's a type, and zero or
> more alternative names for it. The example above makes my_s_t a
> synonym for s, not s_t.
Right. "Hierarchy" was probably a poor choice of a term for this.
I didn't mean hierarchy in the language sense but in the AST sense.
GCC already creates a separate *_TYPE node for each typedef alias.
And you can get from any such node to the "primary node", or root
of the tree, using the TYPE_MAIN_VARIANT() macro. What I want is
to get the parent node, not the root node.
> Consider this valid code:
>
> typedef int foo;
> typedef int bar;
> typedef foo bar;
> typedef bar foo;
>
> What do you expect to see here?
Any sensible (e.g., ignoring all re-declarations) tree would work for
me. I don't particularly care if my code doesn't produce the desired
result for clinical cases like the above.
> You want to track size_t, what if someone uses __typeof__(sizeof(1)),
> does that count?
I am fine with it not counting.
> What about std::size_t?
This one is actually covered. In GCC AST std::size_t node is the same
as ::size_t (i.e., GCC does not create new *_TYPE node for using-
declarations).
> That could be defined as a synonym for __SIZE_TYPE__ or decltype(sizeof(1))
> so is not in a sequence of typedef declarations that includes size_t.
If it were defined as one of these, I could then check for both ::size_t
and ::std::size_t.
Thanks,
Boris