* gcc-interface/decl.c (gnat_to_gnu_entity): Minor tweak.
authorebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 May 2015 20:59:27 +0000 (20:59 +0000)
committerebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 25 May 2015 20:59:27 +0000 (20:59 +0000)
* gcc-interface/trans.c (finalize_nrv_unc_r): Use CONSTRUCTOR_ELT.
* gcc-interface/utils.c (convert): Likewise and simplify.
(remove_conversions): Likewise.
* gcc-interface/utils2.c (compare_fat_pointers): Likewise.
(build_unary_op): Likewise and simplify.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@223653 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ada/ChangeLog
gcc/ada/gcc-interface/decl.c
gcc/ada/gcc-interface/trans.c
gcc/ada/gcc-interface/utils.c
gcc/ada/gcc-interface/utils2.c

index eb0a3ba..41af09a 100644 (file)
@@ -1,5 +1,14 @@
 2015-05-25  Eric Botcazou  <ebotcazou@adacore.com>
 
+       * gcc-interface/decl.c (gnat_to_gnu_entity): Minor tweak.
+       * gcc-interface/trans.c (finalize_nrv_unc_r): Use CONSTRUCTOR_ELT.
+       * gcc-interface/utils.c (convert): Likewise and simplify.
+       (remove_conversions): Likewise.
+       * gcc-interface/utils2.c (compare_fat_pointers): Likewise.
+       (build_unary_op): Likewise and simplify.
+
+2015-05-25  Eric Botcazou  <ebotcazou@adacore.com>
+
        * gcc-interface/gigi.h (build_atomic_load): Adjust prototype.
        (build_atomic_store): Likewise.
        (build_load_modify_store): Declare.
index 27f906d..501b076 100644 (file)
@@ -1335,8 +1335,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
                      = TREE_TYPE (DECL_CHAIN (TYPE_FIELDS (gnu_alloc_type)));
 
                    if (TREE_CODE (gnu_expr) == CONSTRUCTOR
-                       && 1 == vec_safe_length (CONSTRUCTOR_ELTS (gnu_expr)))
-                     gnu_expr = 0;
+                       && vec_safe_length (CONSTRUCTOR_ELTS (gnu_expr)) == 1)
+                     gnu_expr = NULL_TREE;
                    else
                      gnu_expr
                        = build_component_ref
index 3c957a6..cb8662c 100644 (file)
@@ -3309,12 +3309,12 @@ finalize_nrv_unc_r (tree *tp, int *walk_subtrees, void *data)
       if (TREE_CODE (ret_val) == COMPOUND_EXPR
          && TREE_CODE (TREE_OPERAND (ret_val, 0)) == INIT_EXPR)
        {
+         tree rhs = TREE_OPERAND (TREE_OPERAND (ret_val, 0), 1);
+
          if (TYPE_IS_FAT_POINTER_P (TREE_TYPE (ret_val)))
-           ret_val
-             = (*CONSTRUCTOR_ELTS (TREE_OPERAND (TREE_OPERAND (ret_val, 0),
-                                               1)))[1].value;
+           ret_val = CONSTRUCTOR_ELT (rhs, 1)->value;
          else
-           ret_val = TREE_OPERAND (TREE_OPERAND (ret_val, 0), 1);
+           ret_val = rhs;
        }
 
       /* Strip useless conversions around the return value.  */
@@ -3365,20 +3365,21 @@ finalize_nrv_unc_r (tree *tp, int *walk_subtrees, void *data)
 
       if (TYPE_IS_FAT_POINTER_P (TREE_TYPE (alloc)))
        {
+         tree cst = TREE_OPERAND (alloc, 1);
+
          /* The new initial value is a COMPOUND_EXPR with the allocation in
             the first arm and the value of P_ARRAY in the second arm.  */
          DECL_INITIAL (new_var)
            = build2 (COMPOUND_EXPR, TREE_TYPE (new_var),
                      TREE_OPERAND (alloc, 0),
-                     (*CONSTRUCTOR_ELTS (TREE_OPERAND (alloc, 1)))[0].value);
+                     CONSTRUCTOR_ELT (cst, 0)->value);
 
          /* Build a modified CONSTRUCTOR that references NEW_VAR.  */
          p_array = TYPE_FIELDS (TREE_TYPE (alloc));
          CONSTRUCTOR_APPEND_ELT (v, p_array,
                                  fold_convert (TREE_TYPE (p_array), new_var));
          CONSTRUCTOR_APPEND_ELT (v, DECL_CHAIN (p_array),
-                                 (*CONSTRUCTOR_ELTS (
-                                     TREE_OPERAND (alloc, 1)))[1].value);
+                                 CONSTRUCTOR_ELT (cst, 1)->value);
          new_ret = build_constructor (TREE_TYPE (alloc), v);
        }
       else
index 184c7d5..3cefe11 100644 (file)
@@ -4067,10 +4067,8 @@ convert (tree type, tree expr)
 
       /* If we have just converted to this padded type, just get the
         inner expression.  */
-      if (TREE_CODE (expr) == CONSTRUCTOR
-         && !vec_safe_is_empty (CONSTRUCTOR_ELTS (expr))
-         && (*CONSTRUCTOR_ELTS (expr))[0].index == TYPE_FIELDS (etype))
-       unpadded = (*CONSTRUCTOR_ELTS (expr))[0].value;
+      if (TREE_CODE (expr) == CONSTRUCTOR)
+       unpadded = CONSTRUCTOR_ELT (expr, 0)->value;
 
       /* Otherwise, build an explicit component reference.  */
       else
@@ -4632,7 +4630,7 @@ remove_conversions (tree exp, bool true_address)
          && TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE
          && TYPE_JUSTIFIED_MODULAR_P (TREE_TYPE (exp)))
        return
-         remove_conversions ((*CONSTRUCTOR_ELTS (exp))[0].value, true);
+         remove_conversions (CONSTRUCTOR_ELT (exp, 0)->value, true);
       break;
 
     case COMPONENT_REF:
index aa92382..42587d9 100644 (file)
@@ -461,7 +461,7 @@ compare_fat_pointers (location_t loc, tree result_type, tree p1, tree p2)
 
   /* The constant folder doesn't fold fat pointer types so we do it here.  */
   if (TREE_CODE (p1) == CONSTRUCTOR)
-    p1_array = (*CONSTRUCTOR_ELTS (p1))[0].value;
+    p1_array = CONSTRUCTOR_ELT (p1, 0)->value;
   else
     p1_array = build_component_ref (p1, NULL_TREE,
                                    TYPE_FIELDS (TREE_TYPE (p1)), true);
@@ -472,7 +472,7 @@ compare_fat_pointers (location_t loc, tree result_type, tree p1, tree p2)
                                         null_pointer_node));
 
   if (TREE_CODE (p2) == CONSTRUCTOR)
-    p2_array = (*CONSTRUCTOR_ELTS (p2))[0].value;
+    p2_array = CONSTRUCTOR_ELT (p2, 0)->value;
   else
     p2_array = build_component_ref (p2, NULL_TREE,
                                    TYPE_FIELDS (TREE_TYPE (p2)), true);
@@ -493,14 +493,14 @@ compare_fat_pointers (location_t loc, tree result_type, tree p1, tree p2)
     = fold_build2_loc (loc, EQ_EXPR, result_type, p1_array, p2_array);
 
   if (TREE_CODE (p1) == CONSTRUCTOR)
-    p1_bounds = (*CONSTRUCTOR_ELTS (p1))[1].value;
+    p1_bounds = CONSTRUCTOR_ELT (p1, 1)->value;
   else
     p1_bounds
       = build_component_ref (p1, NULL_TREE,
                             DECL_CHAIN (TYPE_FIELDS (TREE_TYPE (p1))), true);
 
   if (TREE_CODE (p2) == CONSTRUCTOR)
-    p2_bounds = (*CONSTRUCTOR_ELTS (p2))[1].value;
+    p2_bounds = CONSTRUCTOR_ELT (p2, 1)->value;
   else
     p2_bounds
       = build_component_ref (p2, NULL_TREE,
@@ -1445,15 +1445,13 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
              offset = size_binop (PLUS_EXPR, offset,
                                   size_int (bitpos / BITS_PER_UNIT));
 
-             /* Take the address of INNER, convert the offset to void *, and
-                add then.  It will later be converted to the desired result
-                type, if any.  */
-             inner = build_unary_op (ADDR_EXPR, NULL_TREE, inner);
-             inner = convert (ptr_void_type_node, inner);
-             result = build_binary_op (POINTER_PLUS_EXPR, ptr_void_type_node,
+             /* Take the address of INNER, convert it to a pointer to our type
+                and add the offset.  */
+             inner = build_unary_op (ADDR_EXPR,
+                                     build_pointer_type (TREE_TYPE (operand)),
+                                     inner);
+             result = build_binary_op (POINTER_PLUS_EXPR, TREE_TYPE (inner),
                                        inner, offset);
-             result = convert (build_pointer_type (TREE_TYPE (operand)),
-                               result);
              break;
            }
          goto common;
@@ -1464,12 +1462,12 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand)
             a pointer to our type.  */
          if (TYPE_IS_PADDING_P (type))
            {
-             result = (*CONSTRUCTOR_ELTS (operand))[0].value;
-             result = convert (build_pointer_type (TREE_TYPE (operand)),
-                               build_unary_op (ADDR_EXPR, NULL_TREE, result));
+             result
+               = build_unary_op (ADDR_EXPR,
+                                 build_pointer_type (TREE_TYPE (operand)),
+                                 CONSTRUCTOR_ELT (operand, 0)->value);
              break;
            }
-
          goto common;
 
        case NOP_EXPR: