]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-common.c (c_common_get_alias_set): Correctly handle characters.
authorRichard Henderson <rth@redhat.com>
Thu, 20 Jun 2002 07:35:46 +0000 (00:35 -0700)
committerRichard Henderson <rth@gcc.gnu.org>
Thu, 20 Jun 2002 07:35:46 +0000 (00:35 -0700)
        * c-common.c (c_common_get_alias_set): Correctly handle characters.
        Rearrange order of expressions; don't handle vectors here.
        * alias.c (get_alias_set): Let vectors match their components.

From-SVN: r54823

gcc/ChangeLog
gcc/alias.c
gcc/c-common.c

index 3c59ce48977794550d1bfe669af5f9475dda39e4..4a2f57fb6cd53bb965d3a85c46c0de7c53cde6da 100644 (file)
@@ -1,3 +1,9 @@
+2002-06-20  Richard Henderson  <rth@redhat.com>
+
+       * c-common.c (c_common_get_alias_set): Correctly handle characters.
+       Rearrange order of expressions; don't handle vectors here.
+       * alias.c (get_alias_set): Let vectors match their components.
+
 2002-06-17  Hans-Peter Nilsson  <hp@axis.com>
 
        PR target/7042
index c5a6265160322c87859f34bf27353ec4f7aeb0b1..6d4104e640b5ed7043f9ca57877d2c4e64e1aa74 100644 (file)
@@ -564,6 +564,14 @@ get_alias_set (t)
      and references to functions, but that's different.)  */
   else if (TREE_CODE (t) == FUNCTION_TYPE)
     set = 0;
+
+  /* Unless the language specifies otherwise, let vector types alias
+     their components.  This avoids some nasty type punning issues in
+     normal usage.  And indeed lets vectors be treated more like an
+     array slice.  */
+  else if (TREE_CODE (t) == VECTOR_TYPE)
+    set = get_alias_set (TREE_TYPE (t));
+
   else
     /* Otherwise make a new alias set for this type.  */
     set = new_alias_set ();
index 5b8b56546268422cf631e0c589fc2105686a570c..f9e593057a9bb7eb51c273768ce31175f112f3b6 100644 (file)
@@ -2326,10 +2326,6 @@ c_common_get_alias_set (t)
 {
   tree u;
   
-  /* We know nothing about vector types */
-  if (TREE_CODE (t) == VECTOR_TYPE)
-    return 0;          
-  
   /* Permit type-punning when accessing a union, provided the access
      is directly through the union.  For example, this code does not
      permit taking the address of a union member and then storing
@@ -2343,17 +2339,17 @@ c_common_get_alias_set (t)
        && TREE_CODE (TREE_TYPE (TREE_OPERAND (u, 0))) == UNION_TYPE)
       return 0;
 
-  /* If this is a char *, the ANSI C standard says it can alias
-     anything.  Note that all references need do this.  */
-  if (TREE_CODE_CLASS (TREE_CODE (t)) == 'r'
-      && TREE_CODE (TREE_TYPE (t)) == INTEGER_TYPE
-      && TYPE_PRECISION (TREE_TYPE (t)) == TYPE_PRECISION (char_type_node))
-    return 0;
-
   /* That's all the expressions we handle specially.  */
   if (! TYPE_P (t))
     return -1;
 
+  /* The C standard guarantess that any object may be accessed via an
+     lvalue that has character type.  */
+  if (t == char_type_node
+      || t == signed_char_type_node
+      || t == unsigned_char_type_node)
+    return 0;
+  
   /* The C standard specifically allows aliasing between signed and
      unsigned variants of the same type.  We treat the signed
      variant as canonical.  */