From f2ee215beb3e13681e952395335f30dec161876a Mon Sep 17 00:00:00 2001 From: Brendan Kehoe Date: Thu, 14 May 1998 12:29:41 +0000 Subject: [PATCH] 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 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/cp-tree.h | 1 + gcc/cp/typeck.c | 27 +++++++++++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8cfb061f6645..bdd7a16bcef8 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +Thu May 14 12:27:34 1998 Brendan Kehoe + + * 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 * Makefile.in (lex.o): Depend on output.h. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 183578bcf69b..17e3ac8020a7 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.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)); diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 27a9c6e010d3..481467f27720 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -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) -- 2.47.3