Hi,

now that TYPE_IDENTIFIER includes an explicit check that TYPE_NAME is nonnull, we can remove a few redundant uses of the latter. Plus a few additional tweaks. Tested x86_64-linux.

Thanks,
Paolo.

///////////////////


2014-04-15  Paolo Carlini  <paolo.carl...@oracle.com>

        * decl.c (duplicate_decls): Remove redundant TYPE_NAME use.
        * name-lookup.c (pushdecl_maybe_friend_1): Likewise.
        (do_class_using_decl): Likewise.
        (set_identifier_type_value): Use TYPE_LINKAGE_IDENTIFIER.
        * pt.c (resolve_typename_type): Likewise.
        * mangle.c (dump_substitution_candidates): Use TYPE_NAME_STRING.
Index: decl.c
===================================================================
--- decl.c      (revision 209408)
+++ decl.c      (working copy)
@@ -1380,7 +1380,6 @@ duplicate_decls (tree newdecl, tree olddecl, bool
                    tree t = TREE_VALUE (t1);
 
                    if (TYPE_PTR_P (t)
-                       && TYPE_NAME (TREE_TYPE (t))
                        && TYPE_IDENTIFIER (TREE_TYPE (t))
                           == get_identifier ("FILE")
                        && compparms (TREE_CHAIN (t1), TREE_CHAIN (t2)))
Index: mangle.c
===================================================================
--- mangle.c    (revision 209408)
+++ mangle.c    (working copy)
@@ -323,7 +323,7 @@ dump_substitution_candidates (void)
       else if (TREE_CODE (el) == TREE_LIST)
        name = IDENTIFIER_POINTER (DECL_NAME (TREE_VALUE (el)));
       else if (TYPE_NAME (el))
-       name = IDENTIFIER_POINTER (TYPE_IDENTIFIER (el));
+       name = TYPE_NAME_STRING (el);
       fprintf (stderr, " S%d_ = ", i - 1);
       if (TYPE_P (el) &&
          (CP_TYPE_RESTRICT_P (el)
Index: name-lookup.c
===================================================================
--- name-lookup.c       (revision 209408)
+++ name-lookup.c       (working copy)
@@ -945,7 +945,6 @@ pushdecl_maybe_friend_1 (tree x, bool is_friend)
            set_underlying_type (x);
 
          if (type != error_mark_node
-             && TYPE_NAME (type)
              && TYPE_IDENTIFIER (type))
            set_identifier_type_value (DECL_NAME (x), x);
 
@@ -2017,7 +2016,7 @@ set_identifier_type_value (tree id, tree decl)
 static inline tree
 constructor_name_full (tree type)
 {
-  return TYPE_IDENTIFIER (TYPE_MAIN_VARIANT (type));
+  return TYPE_LINKAGE_IDENTIFIER (type);
 }
 
 /* Return the name for the constructor (or destructor) for the
@@ -3333,7 +3332,7 @@ do_class_using_decl (tree scope, tree name)
     }
   /* Using T::T declares inheriting ctors, even if T is a typedef.  */
   if (MAYBE_CLASS_TYPE_P (scope)
-      && ((TYPE_NAME (scope) && name == TYPE_IDENTIFIER (scope))
+      && (name == TYPE_IDENTIFIER (scope)
          || constructor_name_p (name, scope)))
     {
       maybe_warn_cpp0x (CPP0X_INHERITING_CTORS);
Index: pt.c
===================================================================
--- pt.c        (revision 209408)
+++ pt.c        (working copy)
@@ -21335,13 +21335,13 @@ resolve_typename_type (tree type, bool only_curren
   scope = TYPE_CONTEXT (type);
   /* Usually the non-qualified identifier of a TYPENAME_TYPE is
      TYPE_IDENTIFIER (type). But when 'type' is a typedef variant of
-     a TYPENAME_TYPE node, then TYPE_NAME (type) is set to the TYPE_DECL 
representing
-     the typedef. In that case TYPE_IDENTIFIER (type) is not the non-qualified
-     identifier  of the TYPENAME_TYPE anymore.
+     a TYPENAME_TYPE node, then TYPE_NAME (type) is set to the TYPE_DECL
+     representing the typedef.  In that case TYPE_IDENTIFIER (type) is
+     not the non-qualified identifier of the TYPENAME_TYPE anymore.
      So by getting the TYPE_IDENTIFIER of the _main declaration_ of the
      TYPENAME_TYPE instead, we avoid messing up with a possible
      typedef variant case.  */
-  name = TYPE_IDENTIFIER (TYPE_MAIN_VARIANT (type));
+  name = TYPE_LINKAGE_IDENTIFIER (type);
 
   /* If the SCOPE is itself a TYPENAME_TYPE, then we need to resolve
      it first before we can figure out what NAME refers to.  */

Reply via email to