diff options
author | Brendan Kehoe <brendan@cygnus.com> | 1998-05-14 12:29:41 +0000 |
---|---|---|
committer | Brendan Kehoe <brendan@gcc.gnu.org> | 1998-05-14 08:29:41 -0400 |
commit | f2ee215beb3e13681e952395335f30dec161876a (patch) | |
tree | b46d82143ac93832e81c471489654b32a8aaa020 /gcc | |
parent | c02cdb7030f74dbc00ea23a6cb02ed929c100a82 (diff) | |
download | gcc-f2ee215beb3e13681e952395335f30dec161876a.zip gcc-f2ee215beb3e13681e952395335f30dec161876a.tar.gz gcc-f2ee215beb3e13681e952395335f30dec161876a.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/cp/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 1 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 27 |
3 files changed, 33 insertions, 2 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 8cfb061..bdd7a16 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -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. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 183578b..17e3ac8 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 27a9c6e..481467f 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) |