On 06/08/2011 03:31 PM, Steven Bosscher wrote:
The rest are all in cp/.  It looks like g++ uses TREE_TYPE as a cache
for name lookups. Perhaps Jason can comment. Obviously not a front end
I know very well, but let's look at them one at a time:

cp/cp-tree.h:  (DECL_CONV_FN_P (FN) ? TREE_TYPE (DECL_NAME (FN)) : NULL_TREE)

Apparently g++ puts the type of an operator in TREE_TYPE of an
IDENTIFIER_NODE. This should probably be using
REAL_IDENTIFIER_TYPE_VALUE() instead of TREE_TYPE().

Yes, this is to associate the name of a type conversion operator with the type it converts to. Using a different macro would be fine.

cp/decl.c:        if (TREE_TYPE (DECL_NAME (decl))&&  TREE_TYPE (decl) != type)

This is in a warning for a type declaration shadowing a local or class
scope.  Should use identifier_type_value (or
REAL_IDENTIFIER_TYPE_VALUE but I think that's supposed to be used
directly only in name-lookup.c??)

Sure, identifier_type_value would work. But that code looks bitrotted; type is always equal to TREE_TYPE (decl). I'd be inclined to try removing it and seeing if anything breaks.

cp/decl2.c:       tree underlying_type = TREE_TYPE (DECL_NAME (decl));
cp/decl2.c:         (decl, type_visibility (TREE_TYPE (DECL_NAME (decl))));
cp/decl2.c:&&  CLASS_TYPE_P (TREE_TYPE (DECL_NAME (decl)))
cp/decl2.c:&&  !CLASSTYPE_VISIBILITY_SPECIFIED (TREE_TYPE
(DECL_NAME (decl))))
cp/decl2.c:      tree type = TREE_TYPE (DECL_NAME (decl));
cp/repo.c:      type = TREE_TYPE (DECL_NAME (decl));
cp/rtti.c:  tree type = TREE_TYPE (DECL_NAME (decl));

All of these are covered by a check on DECL_TINFO_P. I am not sure
what that means but probably these should also be using
identifier_type_value or REAL_IDENTIFIER_TYPE_VALUE instead of
TREE_TYPE. Jason?

This is a way of finding the class a type_info node/vtable pertains to. Using a different lookup strategy would be fine.

Jason

Reply via email to