From: Eric Botcazou <ebotca...@adacore.com> This declares an explicit temporary for the fields of the fat pointer type in gnat_to_gnu_entity and removes the GNU_ prefix of the parameters of the relate_alias_sets routine for the sake of brevity. No functional changes.
gcc/ada/ * gcc-interface/decl.cc (gnat_to_gnu_entity) <E_Array_Type>: Use a separate FLD local variable to hold the first field of the fat pointer type being built. * gcc-interface/gigi.h (relate_alias_sets): Remove GNU_ prefix on the first two parameters. * gcc-interface/utils.cc (relate_alias_sets): Likewise and adjust. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/gcc-interface/decl.cc | 27 +++++++++---------- gcc/ada/gcc-interface/gigi.h | 4 +-- gcc/ada/gcc-interface/utils.cc | 48 ++++++++++++++++------------------ 3 files changed, 38 insertions(+), 41 deletions(-) diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc index 89a374fab1a..221baebb554 100644 --- a/gcc/ada/gcc-interface/decl.cc +++ b/gcc/ada/gcc-interface/decl.cc @@ -2111,7 +2111,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) tree *gnu_index_types = XALLOCAVEC (tree, ndim); tree *gnu_temp_fields = XALLOCAVEC (tree, ndim); tree gnu_max_size = size_one_node; - tree comp_type, tem, obj; + tree comp_type, fld, tem, obj; Entity_Id gnat_index; alias_set_type ptr_set = -1; int index; @@ -2184,11 +2184,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) if the FIELD_DECLs are distinct as objects. */ if (COMPLETE_TYPE_P (gnu_fat_type)) { - tem = TYPE_FIELDS (gnu_fat_type); - if (TYPE_ALIAS_SET_KNOWN_P (TREE_TYPE (tem))) - ptr_set = TYPE_ALIAS_SET (TREE_TYPE (tem)); - TREE_TYPE (tem) = ptr_type_node; - TREE_TYPE (DECL_CHAIN (tem)) = gnu_ptr_template; + fld = TYPE_FIELDS (gnu_fat_type); + if (TYPE_ALIAS_SET_KNOWN_P (TREE_TYPE (fld))) + ptr_set = TYPE_ALIAS_SET (TREE_TYPE (fld)); + TREE_TYPE (fld) = ptr_type_node; + TREE_TYPE (DECL_CHAIN (fld)) = gnu_ptr_template; TYPE_DECL_SUPPRESS_DEBUG (TYPE_STUB_DECL (gnu_fat_type)) = 0; for (tree t = gnu_fat_type; t; t = TYPE_NEXT_VARIANT (t)) SET_TYPE_UNCONSTRAINED_ARRAY (t, gnu_type); @@ -2197,15 +2197,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) { /* We make the fields addressable for the sake of compatibility with languages for which the regular fields are addressable. */ - tem + fld = create_field_decl (get_identifier ("P_ARRAY"), ptr_type_node, gnu_fat_type, NULL_TREE, NULL_TREE, 0, 1); - DECL_CHAIN (tem) + DECL_CHAIN (fld) = create_field_decl (get_identifier ("P_BOUNDS"), gnu_ptr_template, gnu_fat_type, NULL_TREE, NULL_TREE, 0, 1); - finish_fat_pointer_type (gnu_fat_type, tem); + finish_fat_pointer_type (gnu_fat_type, fld); SET_TYPE_UNCONSTRAINED_ARRAY (gnu_fat_type, gnu_type); } @@ -2230,7 +2230,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) fields once we build them. */ tem = build3 (COMPONENT_REF, gnu_ptr_template, build0 (PLACEHOLDER_EXPR, gnu_fat_type), - DECL_CHAIN (TYPE_FIELDS (gnu_fat_type)), NULL_TREE); + DECL_CHAIN (fld), NULL_TREE); gnu_template_reference = build_unary_op (INDIRECT_REF, gnu_template_type, tem); TREE_READONLY (gnu_template_reference) = 1; @@ -2413,12 +2413,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) type since the implementation type may vary between constrained subtypes and unconstrained base type. */ if (Present (PAT)) - TREE_TYPE (TYPE_FIELDS (gnu_fat_type)) - = build_pointer_type_for_mode (tem, ptr_mode, true); + TREE_TYPE (fld) = build_pointer_type_for_mode (tem, ptr_mode, true); else - TREE_TYPE (TYPE_FIELDS (gnu_fat_type)) = build_pointer_type (tem); + TREE_TYPE (fld) = build_pointer_type (tem); if (ptr_set != -1) - TYPE_ALIAS_SET (TREE_TYPE (TYPE_FIELDS (gnu_fat_type))) = ptr_set; + TYPE_ALIAS_SET (TREE_TYPE (fld)) = ptr_set; /* If the maximum size doesn't overflow, use it. */ if (gnu_max_size diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index 2a7320f0a4b..c1bc237e68e 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -158,14 +158,14 @@ enum alias_set_op ALIAS_SET_SUPERSET }; -/* Relate the alias sets of GNU_NEW_TYPE and GNU_OLD_TYPE according to OP. +/* Relate the alias sets of NEW_TYPE and OLD_TYPE according to OP. If this is a multi-dimensional array type, do this recursively. OP may be - ALIAS_SET_COPY: the new set is made a copy of the old one. - ALIAS_SET_SUPERSET: the new set is made a superset of the old one. - ALIAS_SET_SUBSET: the new set is made a subset of the old one. */ -extern void relate_alias_sets (tree gnu_new_type, tree gnu_old_type, +extern void relate_alias_sets (tree new_type, tree old_type, enum alias_set_op op); /* Given GNAT_ENTITY, an object (constant, variable, parameter, exception) diff --git a/gcc/ada/gcc-interface/utils.cc b/gcc/ada/gcc-interface/utils.cc index 17f6afd687d..bc063c20387 100644 --- a/gcc/ada/gcc-interface/utils.cc +++ b/gcc/ada/gcc-interface/utils.cc @@ -1823,7 +1823,7 @@ set_reverse_storage_order_on_pad_type (tree type) return canonicalize_pad_type (type); } -/* Relate the alias sets of GNU_NEW_TYPE and GNU_OLD_TYPE according to OP. +/* Relate the alias sets of NEW_TYPE and OLD_TYPE according to OP. If this is a multi-dimensional array type, do this recursively. OP may be @@ -1832,30 +1832,28 @@ set_reverse_storage_order_on_pad_type (tree type) - ALIAS_SET_SUBSET: the new set is made a subset of the old one. */ void -relate_alias_sets (tree gnu_new_type, tree gnu_old_type, enum alias_set_op op) +relate_alias_sets (tree new_type, tree old_type, enum alias_set_op op) { /* Remove any padding from GNU_OLD_TYPE. It doesn't matter in the case of a one-dimensional array, since the padding has the same alias set as the field type, but if it's a multi-dimensional array, we need to see the inner types. */ - while (TREE_CODE (gnu_old_type) == RECORD_TYPE - && (TYPE_JUSTIFIED_MODULAR_P (gnu_old_type) - || TYPE_PADDING_P (gnu_old_type))) - gnu_old_type = TREE_TYPE (TYPE_FIELDS (gnu_old_type)); + while (TREE_CODE (old_type) == RECORD_TYPE + && (TYPE_JUSTIFIED_MODULAR_P (old_type) + || TYPE_PADDING_P (old_type))) + old_type = TREE_TYPE (TYPE_FIELDS (old_type)); /* Unconstrained array types are deemed incomplete and would thus be given alias set 0. Retrieve the underlying array type. */ - if (TREE_CODE (gnu_old_type) == UNCONSTRAINED_ARRAY_TYPE) - gnu_old_type - = TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_old_type)))); - if (TREE_CODE (gnu_new_type) == UNCONSTRAINED_ARRAY_TYPE) - gnu_new_type - = TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_new_type)))); - - if (TREE_CODE (gnu_new_type) == ARRAY_TYPE - && TREE_CODE (TREE_TYPE (gnu_new_type)) == ARRAY_TYPE - && TYPE_MULTI_ARRAY_P (TREE_TYPE (gnu_new_type))) - relate_alias_sets (TREE_TYPE (gnu_new_type), TREE_TYPE (gnu_old_type), op); + if (TREE_CODE (old_type) == UNCONSTRAINED_ARRAY_TYPE) + old_type = TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (old_type)))); + if (TREE_CODE (new_type) == UNCONSTRAINED_ARRAY_TYPE) + new_type = TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (new_type)))); + + if (TREE_CODE (new_type) == ARRAY_TYPE + && TREE_CODE (TREE_TYPE (new_type)) == ARRAY_TYPE + && TYPE_MULTI_ARRAY_P (TREE_TYPE (new_type))) + relate_alias_sets (TREE_TYPE (new_type), TREE_TYPE (old_type), op); switch (op) { @@ -1864,19 +1862,19 @@ relate_alias_sets (tree gnu_new_type, tree gnu_old_type, enum alias_set_op op) aliasing settings because this can break the aliasing relationship between the array type and its element type. */ if (flag_checking || flag_strict_aliasing) - gcc_assert (!(TREE_CODE (gnu_new_type) == ARRAY_TYPE - && TREE_CODE (gnu_old_type) == ARRAY_TYPE - && TYPE_NONALIASED_COMPONENT (gnu_new_type) - != TYPE_NONALIASED_COMPONENT (gnu_old_type))); + gcc_assert (!(TREE_CODE (new_type) == ARRAY_TYPE + && TREE_CODE (old_type) == ARRAY_TYPE + && TYPE_NONALIASED_COMPONENT (new_type) + != TYPE_NONALIASED_COMPONENT (old_type))); - TYPE_ALIAS_SET (gnu_new_type) = get_alias_set (gnu_old_type); + TYPE_ALIAS_SET (new_type) = get_alias_set (old_type); break; case ALIAS_SET_SUBSET: case ALIAS_SET_SUPERSET: { - alias_set_type old_set = get_alias_set (gnu_old_type); - alias_set_type new_set = get_alias_set (gnu_new_type); + alias_set_type old_set = get_alias_set (old_type); + alias_set_type new_set = get_alias_set (new_type); /* Do nothing if the alias sets conflict. This ensures that we never call record_alias_subset several times for the same pair @@ -1895,7 +1893,7 @@ relate_alias_sets (tree gnu_new_type, tree gnu_old_type, enum alias_set_op op) gcc_unreachable (); } - record_component_aliases (gnu_new_type); + record_component_aliases (new_type); } /* Record TYPE as a builtin type for Ada. NAME is the name of the type. -- 2.43.0