c-common.c (c_get_alias_set): Fix support for poitners and references.
authorMike Stump <mrs@wrs.com>
Thu, 19 Aug 1999 21:39:04 +0000 (21:39 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 19 Aug 1999 21:39:04 +0000 (21:39 +0000)
* c-common.c (c_get_alias_set): Fix support for poitners and
references.

Co-Authored-By: Mark Mitchell <mark@codesourcery.com>
From-SVN: r28768

gcc/ChangeLog
gcc/c-common.c

index 046606b1f661a6cee2058252bf0eff27f8812998..8f83f30f17fcbd2640b8bbdb854d18e73a6c0c9e 100644 (file)
@@ -1,3 +1,9 @@
+Thu Aug 19 14:42:38 1999  Mike Stump <mrs@wrs.com>
+                         Mark Mitchell <mark@codesourcery.com>
+
+       * 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.
index 137d1d3d9f3ba48d19a96ff7bc841b8471f20bb0..d194be625e46719d2ac0c48e017a4199e77fc852 100644 (file)
@@ -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);
 }