summaryrefslogtreecommitdiff
path: root/gcc/c-common.c
diff options
context:
space:
mode:
authorMike Stump <mrs@wrs.com>1999-08-19 21:39:04 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1999-08-19 21:39:04 +0000
commit02af3af6514c82ca3bc75aa75b2774073f0ce602 (patch)
tree25c740c2a068a0f2acc3146f3aad5ba91086744b /gcc/c-common.c
parent2aaf816dad783f6cfccae11e356a5213a2455adf (diff)
downloadgcc-02af3af6514c82ca3bc75aa75b2774073f0ce602.tar.gz
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 <mark@codesourcery.com> From-SVN: r28768
Diffstat (limited to 'gcc/c-common.c')
-rw-r--r--gcc/c-common.c36
1 files changed, 33 insertions, 3 deletions
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);
}