From 02af3af6514c82ca3bc75aa75b2774073f0ce602 Mon Sep 17 00:00:00 2001 From: Mike Stump Date: Thu, 19 Aug 1999 21:39:04 +0000 Subject: [PATCH] c-common.c (c_get_alias_set): Fix support for poitners and references. * c-common.c (c_get_alias_set): Fix support for poitners and references. Co-Authored-By: Mark Mitchell From-SVN: r28768 --- gcc/ChangeLog | 6 ++++++ gcc/c-common.c | 36 +++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 046606b1f66..8f83f30f17f 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +Thu Aug 19 14:42:38 1999 Mike Stump + Mark Mitchell + + * c-common.c (c_get_alias_set): Fix support for poitners and + references. + Thu Aug 19 11:51:22 EDT 1999 John Wehle (john@feith.com) * alias.c: Include tree.h. diff --git a/gcc/c-common.c b/gcc/c-common.c index 137d1d3d9f3..d194be625e4 100644 --- a/gcc/c-common.c +++ b/gcc/c-common.c @@ -3401,11 +3401,41 @@ c_get_alias_set (t) whose type is the same as one of the fields, recursively, but we don't yet make any use of that information.) */ TYPE_ALIAS_SET (type) = 0; + else if (TREE_CODE (type) == POINTER_TYPE + || TREE_CODE (type) == REFERENCE_TYPE) + { + tree t; + + /* Unfortunately, there is no canonical form of a pointer type. + In particular, if we have `typedef int I', then `int *', and + `I *' are different types. So, we have to pick a canonical + representative. We do this below. + + Note that this approach is actually more conservative that it + needs to be. In particular, `const int *' and `int *' should + be in different alias sets, but this approach puts them in + the same alias set. */ + + t = TYPE_MAIN_VARIANT (TREE_TYPE (type)); + t = ((TREE_CODE (type) == POINTER_TYPE) + ? build_pointer_type (t) : build_reference_type (t)); + if (t != type) + TYPE_ALIAS_SET (type) = c_get_alias_set (t); + } if (!TYPE_ALIAS_SET_KNOWN_P (type)) - /* TYPE is something we haven't seen before. Put it in a new - alias set. */ - TYPE_ALIAS_SET (type) = new_alias_set (); + { + /* Types that are not allocated on the permanent obstack are not + placed in the type hash table. Thus, there can be multiple + copies of identical types in local scopes. In the long run, + all types should be permanent. */ + if (! TREE_PERMANENT (type)) + TYPE_ALIAS_SET (type) = 0; + else + /* TYPE is something we haven't seen before. Put it in a new + alias set. */ + TYPE_ALIAS_SET (type) = new_alias_set (); + } return TYPE_ALIAS_SET (type); } -- 2.30.2