* 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
+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.
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));
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.
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)