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.
= 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
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. */
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
/* 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
&& 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:
/* 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);
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);
= 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,
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;
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: