Commit f2ee215b by Brendan Kehoe Committed by Brendan Kehoe

typeck.c (original_type): New function.

	* 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
parent c02cdb70
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.
......
......@@ -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));
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment