typeck.c (original_type): New function.
authorBrendan Kehoe <brendan@cygnus.com>
Thu, 14 May 1998 12:29:41 +0000 (12:29 +0000)
committerBrendan Kehoe <brendan@gcc.gnu.org>
Thu, 14 May 1998 12:29:41 +0000 (08:29 -0400)
* typeck.c (original_type): New function.
(common_type): Use it to get the DECL_ORIGINAL_TYPE for T1 and T2,
to see if they're actually the same.
* cp-tree.h (original_type): Declare.
fix problem when you have multiple identical typedefs

From-SVN: r19744

gcc/cp/ChangeLog
gcc/cp/cp-tree.h
gcc/cp/typeck.c

index 8cfb061f6645a9f5045cf3f76c6e645d0e591596..bdd7a16bcef86c94987aa6db4b5398a47a41e733 100644 (file)
@@ -1,3 +1,10 @@
+Thu May 14 12:27:34 1998  Brendan Kehoe  <brendan@cygnus.com>
+
+       * typeck.c (original_type): New function.
+       (common_type): Use it to get the DECL_ORIGINAL_TYPE for T1 and T2,
+       to see if they're actually the same.
+       * cp-tree.h (original_type): Declare.
+
 Wed May 13 12:54:30 1998  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>
 
        * Makefile.in (lex.o): Depend on output.h.
index 183578bcf69b8d33dc96ee99c5427dd64c510885..17e3ac8020a71a330e8d69ab871b63d1541c6cd1 100644 (file)
@@ -2760,6 +2760,7 @@ extern int type_unknown_p                 PROTO((tree));
 extern int fntype_p                            PROTO((tree));
 extern tree require_instantiated_type          PROTO((tree, tree, tree));
 extern tree commonparms                                PROTO((tree, tree));
+extern tree original_type                      PROTO((tree));
 extern tree common_type                                PROTO((tree, tree));
 extern int compexcepttypes                     PROTO((tree, tree));
 extern int comptypes                           PROTO((tree, tree, int));
index 27a9c6e010d34975d4a21e99f4d10f79bd9934ed..481467f2772047f6f69ef8c73085704f45371cf4 100644 (file)
@@ -292,6 +292,25 @@ commonparms (p1, p2)
   return newargs;
 }
 
+/* Given a type, perhaps copied for a typedef,
+   find the "original" version of it.  */
+tree
+original_type (t)
+     tree t;
+{
+  while (TYPE_NAME (t) != NULL_TREE)
+    {
+      tree x = TYPE_NAME (t);
+      if (TREE_CODE (x) != TYPE_DECL)
+       break;
+      x = DECL_ORIGINAL_TYPE (x);
+      if (x == NULL_TREE)
+       break;
+      t = x;
+    }
+  return t;
+}
+
 /* Return the common type of two types.
    We assume that comptypes has already been done and returned 1;
    if that isn't so, this may crash.
@@ -311,8 +330,12 @@ common_type (t1, t2)
   tree attributes;
 
   /* Save time if the two types are the same.  */
-
-  if (t1 == t2) return t1;
+  if (t1 == t2)
+    return t1;
+  t1 = original_type (t1);
+  t2 = original_type (t2);
+  if (t1 == t2)
+    return t1;
 
   /* If one type is nonsense, use the other.  */
   if (t1 == error_mark_node)