(build_type_variant): Only return existing type if it
authorJim Wilson <wilson@gcc.gnu.org>
Sat, 20 Aug 1994 00:20:05 +0000 (17:20 -0700)
committerJim Wilson <wilson@gcc.gnu.org>
Sat, 20 Aug 1994 00:20:05 +0000 (17:20 -0700)
also has the same TYPE_NAME.

From-SVN: r7954

gcc/tree.c

index 068f2b73d040a34d712425e27972c20ff2f02156..7b8fb5182c6d3b4c0e654a7b343a93a16437e148 100644 (file)
@@ -2802,19 +2802,14 @@ build_type_variant (type, constp, volatilep)
   constp = !!constp;
   volatilep = !!volatilep;
 
-  /* If not generating auxiliary info, search the chain of variants to see
-     if there is already one there just like the one we need to have.  If so,
-     use that existing one.
-
-     We don't do this in the case where we are generating aux info because
-     in that case we want each typedef names to get it's own distinct type
-     node, even if the type of this new typedef is the same as some other
-     (existing) type.  */
-
-  if (!flag_gen_aux_info)
-    for (t = TYPE_MAIN_VARIANT(type); t; t = TYPE_NEXT_VARIANT (t))
-      if (constp == TYPE_READONLY (t) && volatilep == TYPE_VOLATILE (t))
-        return t;
+  /* Search the chain of variants to see if there is already one there just
+     like the one we need to have.  If so, use that existing one.  We must
+     preserve the TYPE_NAME, since there is code that depends on this.  */
+
+  for (t = TYPE_MAIN_VARIANT(type); t; t = TYPE_NEXT_VARIANT (t))
+    if (constp == TYPE_READONLY (t) && volatilep == TYPE_VOLATILE (t)
+       && TYPE_NAME (t) == TYPE_NAME (type))
+      return t;
 
   /* We need a new one.  */