]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c-typeck.c (default_function_array_conversion): Always create &a[0] for array types.
authorAndrew Pinski <pinskia@physics.uc.edu>
Sun, 17 Oct 2004 17:16:27 +0000 (17:16 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Sun, 17 Oct 2004 17:16:27 +0000 (10:16 -0700)
2004-10-17  Andrew Pinski  <pinskia@physics.uc.edu>

        * c-typeck.c (default_function_array_conversion): Always create
        &a[0] for array types.
        (build_unary_op): Do not fold &a[x] into a + x.

From-SVN: r89173

gcc/ChangeLog
gcc/c-typeck.c

index 91e97316f02bcaa77f512eeaa4d136acf09eddbb..1b9cf8b0846f9bc3f39466ec3ebbc08aaec8966b 100644 (file)
@@ -1,3 +1,9 @@
+2004-10-17  Andrew Pinski  <pinskia@physics.uc.edu>
+
+       * c-typeck.c (default_function_array_conversion): Always create
+       &a[0] for array types.
+       (build_unary_op): Do not fold &a[x] into a + x.
+
 2004-10-17  Jakub Jelinek  <jakub@redhat.com>
 
        * pointer-set.c (hash1): Use integer part of 2^64 / phi
index 9e4f0fb1501261328a318d858854a419ab69fe91..87f585baddb13fa7aaf6f23b13aad889a9b9be8e 100644 (file)
@@ -1263,21 +1263,9 @@ default_function_array_conversion (tree exp)
 
       ptrtype = build_pointer_type (restype);
 
-      if (TREE_CODE (exp) == VAR_DECL)
-       {
-         /* We are making an ADDR_EXPR of ptrtype.  This is a valid
-            ADDR_EXPR because it's the best way of representing what
-            happens in C when we take the address of an array and place
-            it in a pointer to the element type.  */
-         adr = build1 (ADDR_EXPR, ptrtype, exp);
-         if (!c_mark_addressable (exp))
-           return error_mark_node;
-         TREE_SIDE_EFFECTS (adr) = 0;   /* Default would be, same as EXP.  */
-         return adr;
-       }
       /* This way is better for a COMPONENT_REF since it can
         simplify the offset for a component.  */
-      adr = build_unary_op (ADDR_EXPR, exp, 1);
+      adr = build_unary_op (ADDR_EXPR, build_array_ref (exp, integer_zero_node), 1);
       return convert (ptrtype, adr);
     }
   return exp;
@@ -2631,13 +2619,12 @@ build_unary_op (enum tree_code code, tree xarg, int flag)
          return TREE_OPERAND (arg, 0);
        }
 
-      /* For &x[y], return x+y */
+      /* For &x[y], just return &x[y] */
       if (TREE_CODE (arg) == ARRAY_REF)
        {
          if (!c_mark_addressable (TREE_OPERAND (arg, 0)))
            return error_mark_node;
-         return build_binary_op (PLUS_EXPR, TREE_OPERAND (arg, 0),
-                                 TREE_OPERAND (arg, 1), 1);
+          return build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (arg)), arg);
        }
 
       /* Anything not already handled and not a true memory reference