diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2012-03-12 20:00:32 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2012-03-12 20:00:32 +0000 |
commit | 2b45154d2074a11baa2dfa18247848227fbfa1f0 (patch) | |
tree | 1b26a4183158628e3053e92f393f5fa662df3146 /gcc/ada/gcc-interface/utils.c | |
parent | 0452b4d47fe1e13bbcb8578e7e348cef2ca17e42 (diff) | |
download | gcc-2b45154d2074a11baa2dfa18247848227fbfa1f0.zip gcc-2b45154d2074a11baa2dfa18247848227fbfa1f0.tar.gz gcc-2b45154d2074a11baa2dfa18247848227fbfa1f0.tar.bz2 |
gigi.h (shift_unc_components_for_thin_pointers): Kill.
* gcc-interface/gigi.h (shift_unc_components_for_thin_pointers): Kill.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Array_Type>: Remove call
to above function.
* gcc-interface/trans.c (Attribute_to_gnu) <Attr_Pool_Address>: Adjust
handling of thin pointers.
<Attr_Descriptor_Size>: Likewise.
(gnat_to_gnu) <N_Free_Statement>: Likewise.
* gcc-interface/utils.c (shift_unc_components_for_thin_pointers): Kill.
(convert_to_fat_pointer): Adjust handling of thin pointers.
(convert) <POINTER_TYPE>: Likewise.
* gcc-interface/utils2.c (build_unary_op) <INDIRECT_REF>: Likewise.
From-SVN: r185268
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r-- | gcc/ada/gcc-interface/utils.c | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 4f8ab20..7383358 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -3411,27 +3411,6 @@ build_unc_object_type_from_ptr (tree thin_fat_ptr_type, tree object_type, return build_unc_object_type (template_type, object_type, name, debug_info_p); } - -/* Shift the component offsets within an unconstrained object TYPE to make it - suitable for use as a designated type for thin pointers. */ - -void -shift_unc_components_for_thin_pointers (tree type) -{ - /* Thin pointer values designate the ARRAY data of an unconstrained object, - allocated past the BOUNDS template. The designated type is adjusted to - have ARRAY at position zero and the template at a negative offset, so - that COMPONENT_REFs on (*thin_ptr) designate the proper location. */ - - tree bounds_field = TYPE_FIELDS (type); - tree array_field = DECL_CHAIN (TYPE_FIELDS (type)); - - DECL_FIELD_OFFSET (bounds_field) - = size_binop (MINUS_EXPR, size_zero_node, byte_position (array_field)); - - DECL_FIELD_OFFSET (array_field) = size_zero_node; - DECL_FIELD_BIT_OFFSET (array_field) = bitsize_zero_node; -} /* Update anything previously pointing to OLD_TYPE to point to NEW_TYPE. In the normal case this is just two adjustments, but we have more to @@ -3616,7 +3595,18 @@ convert_to_fat_pointer (tree type, tree expr) if (TREE_CODE (expr) == ADDR_EXPR) expr = TREE_OPERAND (expr, 0); else - expr = build1 (INDIRECT_REF, TREE_TYPE (etype), expr); + { + /* If we have a TYPE_UNCONSTRAINED_ARRAY attached to the RECORD_TYPE, + the thin pointer value has been shifted so we first need to shift + it back to get the template address. */ + if (TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (etype))) + expr + = build_binary_op (POINTER_PLUS_EXPR, etype, expr, + fold_build1 (NEGATE_EXPR, sizetype, + byte_position + (DECL_CHAIN (field)))); + expr = build1 (INDIRECT_REF, TREE_TYPE (etype), expr); + } template_tree = build_component_ref (expr, NULL_TREE, field, false); expr = build_unary_op (ADDR_EXPR, NULL_TREE, @@ -4103,12 +4093,19 @@ convert (tree type, tree expr) case POINTER_TYPE: case REFERENCE_TYPE: /* If converting between two thin pointers, adjust if needed to account - for any differing offsets, since one of them might be negative. */ + for differing offsets from the base pointer, depending on whether + there is a TYPE_UNCONSTRAINED_ARRAY attached to the record type. */ if (TYPE_IS_THIN_POINTER_P (etype) && TYPE_IS_THIN_POINTER_P (type)) { - tree byte_diff - = size_diffop (byte_position (TYPE_FIELDS (TREE_TYPE (etype))), - byte_position (TYPE_FIELDS (TREE_TYPE (type)))); + tree etype_pos + = TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (etype)) != NULL_TREE + ? byte_position (DECL_CHAIN (TYPE_FIELDS (TREE_TYPE (etype)))) + : size_zero_node; + tree type_pos + = TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (type)) != NULL_TREE + ? byte_position (DECL_CHAIN (TYPE_FIELDS (TREE_TYPE (type)))) + : size_zero_node; + tree byte_diff = size_diffop (type_pos, etype_pos); expr = build1 (NOP_EXPR, type, expr); if (integer_zerop (byte_diff)) |