utils2.c (build_unary_op): Propagate the TYPE_REF_CAN_ALIAS_ALL flag to the result.
authorEric Botcazou <ebotcazou@adacore.com>
Sat, 22 Sep 2007 13:04:20 +0000 (13:04 +0000)
committerEric Botcazou <ebotcazou@gcc.gnu.org>
Sat, 22 Sep 2007 13:04:20 +0000 (13:04 +0000)
* utils2.c (build_unary_op) <ADDR_EXPR> [INDIRECT_REF]: Propagate
the TYPE_REF_CAN_ALIAS_ALL flag to the result.

From-SVN: r128669

gcc/ada/ChangeLog
gcc/ada/utils2.c

index bd2560cfcac98c2edb20d6f815072024efdadceb..7913e4a37be43cc3a1561ff68d440b079c96cac2 100644 (file)
@@ -1,3 +1,8 @@
+2007-09-22  Eric Botcazou  <ebotcazou@adacore.com>
+
+       * utils2.c (build_unary_op) <ADDR_EXPR> [INDIRECT_REF]: Propagate
+       the TYPE_REF_CAN_ALIAS_ALL flag to the result.
+
 2007-09-21  Olivier Hainque  <hainque@adacore.com>
 
        * utils.c (type_for_nonaliased_component_p): Return false for
index a89545920a6dfffc74bbb5f3c434bf10cc95132d..350358f719ba449f4d49e77689d874660367209f 100644 (file)
@@ -1078,6 +1078,25 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
             GCC wants pointer types for function addresses.  */
          if (!result_type)
            result_type = build_pointer_type (type);
+
+         /* If the underlying object can alias everything, propagate the
+            property since we are effectively retrieving the object.  */
+         if (POINTER_TYPE_P (TREE_TYPE (result))
+             && TYPE_REF_CAN_ALIAS_ALL (TREE_TYPE (result)))
+           {
+             if (TREE_CODE (result_type) == POINTER_TYPE
+                 && !TYPE_REF_CAN_ALIAS_ALL (result_type))
+               result_type
+                 = build_pointer_type_for_mode (TREE_TYPE (result_type),
+                                                TYPE_MODE (result_type),
+                                                true);
+             else if (TREE_CODE (result_type) == REFERENCE_TYPE
+                      && !TYPE_REF_CAN_ALIAS_ALL (result_type))
+               result_type
+                 = build_reference_type_for_mode (TREE_TYPE (result_type),
+                                                  TYPE_MODE (result_type),
+                                                  true);
+           }
          break;
 
        case NULL_EXPR: