From 315cff155219ea11bf95209165121376b12fe06e Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Fri, 16 Oct 2009 20:07:52 +0000 Subject: [PATCH] ada-tree.h (TYPE_FAT_POINTER_P): Swap with... * gcc-interface/ada-tree.h (TYPE_FAT_POINTER_P): Swap with... (TYPE_IS_FAT_POINTER_P): ...this. (TYPE_THIN_POINTER_P): Rename into... (TYPE_IS_THIN_POINTER_P): ...this. (TYPE_FAT_OR_THIN_POINTER_P): Rename into... (TYPE_IS_FAT_OR_THIN_POINTER_P): ...this. (TYPE_IS_PADDING_P): Change definition, move old one to... (TYPE_PADDING_P): ...this. * gcc-interface/decl.c (gnat_to_gnu_entity): Adjust for above changes. (get_unpadded_type): Likewise. (gnat_to_gnu_component_type): Likewise. (gnat_to_gnu_param): Likewise. (relate_alias_sets): Likewise. (make_packable_type): Likewise. (maybe_pad_type): Likewise. (gnat_to_gnu_field): Likewise. (is_variable_size): Likewise. (annotate_object): Likewise. (validate_size): Likewise. (set_rm_size): Likewise. (make_type_from_size): Likewise. (rm_size): Likewise. * gcc-interface/misc.c (gnat_print_type): Likewise. (gnat_get_alias_set): Likewise. * gcc-interface/trans.c (Identifier_to_gnu): Likewise. (Attribute_to_gnu): Likewise. (call_to_gnu): Likewise. (gnat_to_gnu): Likewise. (add_decl_expr): Likewise. (convert_with_check): Likewise. (addressable_p): Likewise. (maybe_implicit_deref): Likewise. (protect_multiple_eval): Likewise. (gnat_stabilize_reference_1): Likewise. * gcc-interface/utils.c (gnat_pushdecl): Likewise. (finish_record_type): Likewise. (rest_of_record_type_compilation): Likewise. (create_type_decl): Likewise. (gnat_types_compatible_p): Likewise. (build_template): Likewise. (convert_vms_descriptor64): Likewise. (convert_vms_descriptor32): Likewise. (build_unc_object_type_from_ptr): Likewise. (update_pointer_to): Likewise. (convert_to_fat_pointer): Likewise. (convert_to_fat_pointer): Likewise. (convert): Likewise. (remove_conversions): Likewise. (maybe_unconstrained_array): Likewise. (unchecked_convert): Likewise. (handle_vector_type_attribute): Likewise. * gcc-interface/utils2.c (build_binary_op): Likewise. (build_unary_op): Likewise. (build_allocator): Likewise. From-SVN: r152917 --- gcc/ada/ChangeLog | 57 +++++++++++++++++ gcc/ada/gcc-interface/ada-tree.h | 18 +++--- gcc/ada/gcc-interface/decl.c | 101 +++++++++++++------------------ gcc/ada/gcc-interface/misc.c | 5 +- gcc/ada/gcc-interface/trans.c | 83 ++++++++++--------------- gcc/ada/gcc-interface/utils.c | 64 +++++++++----------- gcc/ada/gcc-interface/utils2.c | 44 ++++++-------- 7 files changed, 192 insertions(+), 180 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 4338d03d167..219193f82c5 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,60 @@ +2009-10-16 Eric Botcazou + + * gcc-interface/ada-tree.h (TYPE_FAT_POINTER_P): Swap with... + (TYPE_IS_FAT_POINTER_P): ...this. + (TYPE_THIN_POINTER_P): Rename into... + (TYPE_IS_THIN_POINTER_P): ...this. + (TYPE_FAT_OR_THIN_POINTER_P): Rename into... + (TYPE_IS_FAT_OR_THIN_POINTER_P): ...this. + (TYPE_IS_PADDING_P): Change definition, move old one to... + (TYPE_PADDING_P): ...this. + * gcc-interface/decl.c (gnat_to_gnu_entity): Adjust for above changes. + (get_unpadded_type): Likewise. + (gnat_to_gnu_component_type): Likewise. + (gnat_to_gnu_param): Likewise. + (relate_alias_sets): Likewise. + (make_packable_type): Likewise. + (maybe_pad_type): Likewise. + (gnat_to_gnu_field): Likewise. + (is_variable_size): Likewise. + (annotate_object): Likewise. + (validate_size): Likewise. + (set_rm_size): Likewise. + (make_type_from_size): Likewise. + (rm_size): Likewise. + * gcc-interface/misc.c (gnat_print_type): Likewise. + (gnat_get_alias_set): Likewise. + * gcc-interface/trans.c (Identifier_to_gnu): Likewise. + (Attribute_to_gnu): Likewise. + (call_to_gnu): Likewise. + (gnat_to_gnu): Likewise. + (add_decl_expr): Likewise. + (convert_with_check): Likewise. + (addressable_p): Likewise. + (maybe_implicit_deref): Likewise. + (protect_multiple_eval): Likewise. + (gnat_stabilize_reference_1): Likewise. + * gcc-interface/utils.c (gnat_pushdecl): Likewise. + (finish_record_type): Likewise. + (rest_of_record_type_compilation): Likewise. + (create_type_decl): Likewise. + (gnat_types_compatible_p): Likewise. + (build_template): Likewise. + (convert_vms_descriptor64): Likewise. + (convert_vms_descriptor32): Likewise. + (build_unc_object_type_from_ptr): Likewise. + (update_pointer_to): Likewise. + (convert_to_fat_pointer): Likewise. + (convert_to_fat_pointer): Likewise. + (convert): Likewise. + (remove_conversions): Likewise. + (maybe_unconstrained_array): Likewise. + (unchecked_convert): Likewise. + (handle_vector_type_attribute): Likewise. + * gcc-interface/utils2.c (build_binary_op): Likewise. + (build_unary_op): Likewise. + (build_allocator): Likewise. + 2009-10-16 Eric Botcazou * exp_dbug.ads: Adjust type names in comments. diff --git a/gcc/ada/gcc-interface/ada-tree.h b/gcc/ada/gcc-interface/ada-tree.h index 94b18bde6b5..67a16ef0eb8 100644 --- a/gcc/ada/gcc-interface/ada-tree.h +++ b/gcc/ada/gcc-interface/ada-tree.h @@ -65,11 +65,11 @@ do { \ /* For RECORD_TYPE, UNION_TYPE, and QUAL_UNION_TYPE, nonzero if this is a record being used as a fat pointer (only true for RECORD_TYPE). */ -#define TYPE_IS_FAT_POINTER_P(NODE) \ +#define TYPE_FAT_POINTER_P(NODE) \ TYPE_LANG_FLAG_0 (RECORD_OR_UNION_CHECK (NODE)) -#define TYPE_FAT_POINTER_P(NODE) \ - (TREE_CODE (NODE) == RECORD_TYPE && TYPE_IS_FAT_POINTER_P (NODE)) +#define TYPE_IS_FAT_POINTER_P(NODE) \ + (TREE_CODE (NODE) == RECORD_TYPE && TYPE_FAT_POINTER_P (NODE)) /* For integral types and array types, nonzero if this is a packed array type used for bit-packed types. Such types should not be extended to a larger @@ -117,15 +117,15 @@ do { \ TYPE_LANG_FLAG_3 (INTEGER_TYPE_CHECK (NODE)) /* True if NODE is a thin pointer. */ -#define TYPE_THIN_POINTER_P(NODE) \ +#define TYPE_IS_THIN_POINTER_P(NODE) \ (POINTER_TYPE_P (NODE) \ && TREE_CODE (TREE_TYPE (NODE)) == RECORD_TYPE \ && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (NODE))) /* True if TYPE is either a fat or thin pointer to an unconstrained array. */ -#define TYPE_FAT_OR_THIN_POINTER_P(NODE) \ - (TYPE_FAT_POINTER_P (NODE) || TYPE_THIN_POINTER_P (NODE)) +#define TYPE_IS_FAT_OR_THIN_POINTER_P(NODE) \ + (TYPE_IS_FAT_POINTER_P (NODE) || TYPE_IS_THIN_POINTER_P (NODE)) /* For INTEGER_TYPEs, nonzero if the type has a biased representation. */ #define TYPE_BIASED_REPRESENTATION_P(NODE) \ @@ -143,7 +143,6 @@ do { \ is a dummy type, made to correspond to a private or incomplete type. */ #define TYPE_DUMMY_P(NODE) TYPE_LANG_FLAG_4 (NODE) -/* True if TYPE is such a dummy type. */ #define TYPE_IS_DUMMY_P(NODE) \ ((TREE_CODE (NODE) == VOID_TYPE || TREE_CODE (NODE) == RECORD_TYPE \ || TREE_CODE (NODE) == UNION_TYPE || TREE_CODE (NODE) == ENUMERAL_TYPE) \ @@ -160,7 +159,10 @@ do { \ /* For a RECORD_TYPE, nonzero if this was made just to supply needed padding or alignment. */ -#define TYPE_IS_PADDING_P(NODE) TYPE_LANG_FLAG_5 (RECORD_TYPE_CHECK (NODE)) +#define TYPE_PADDING_P(NODE) TYPE_LANG_FLAG_5 (RECORD_TYPE_CHECK (NODE)) + +#define TYPE_IS_PADDING_P(NODE) \ + (TREE_CODE (NODE) == RECORD_TYPE && TYPE_PADDING_P (NODE)) /* True if TYPE can alias any other types. */ #define TYPE_UNIVERSAL_ALIASING_P(NODE) TYPE_LANG_FLAG_6 (NODE) diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index afef46ec809..a2af1798170 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -676,8 +676,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) despite having a nominal type with self-referential size, we can get the size directly from it. */ if (TREE_CODE (gnu_expr) == COMPONENT_REF - && TREE_CODE (TREE_TYPE (TREE_OPERAND (gnu_expr, 0))) - == RECORD_TYPE && TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (gnu_expr, 0))) && TREE_CODE (TREE_OPERAND (gnu_expr, 0)) == VAR_DECL @@ -852,8 +850,6 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) /* If the renamed object had padding, strip off the reference to the inner object and reset our type. */ if ((TREE_CODE (gnu_expr) == COMPONENT_REF - && TREE_CODE (TREE_TYPE (TREE_OPERAND (gnu_expr, 0))) - == RECORD_TYPE && TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (gnu_expr, 0)))) /* Strip useless conversions around the object. */ || (TREE_CODE (gnu_expr) == NOP_EXPR @@ -1018,14 +1014,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) && TREE_CODE (gnu_type) == RECORD_TYPE && (TYPE_CONTAINS_TEMPLATE_P (gnu_type) /* Beware that padding might have been introduced above. */ - || (TYPE_IS_PADDING_P (gnu_type) + || (TYPE_PADDING_P (gnu_type) && TREE_CODE (TREE_TYPE (TYPE_FIELDS (gnu_type))) == RECORD_TYPE && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (TYPE_FIELDS (gnu_type)))))) { tree template_field - = TYPE_IS_PADDING_P (gnu_type) + = TYPE_PADDING_P (gnu_type) ? TYPE_FIELDS (TREE_TYPE (TYPE_FIELDS (gnu_type))) : TYPE_FIELDS (gnu_type); @@ -1049,17 +1045,16 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) if (gnu_expr && TREE_CODE (gnu_type) != UNCONSTRAINED_ARRAY_TYPE && !CONTAINS_PLACEHOLDER_P (TYPE_SIZE (gnu_type)) - && !(TREE_CODE (gnu_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_type) - && (CONTAINS_PLACEHOLDER_P - (TYPE_SIZE (TREE_TYPE (TYPE_FIELDS (gnu_type))))))) + && !(TYPE_IS_PADDING_P (gnu_type) + && CONTAINS_PLACEHOLDER_P + (TYPE_SIZE (TREE_TYPE (TYPE_FIELDS (gnu_type)))))) gnu_expr = convert (gnu_type, gnu_expr); /* If this is a pointer and it does not have an initializing expression, initialize it to NULL, unless the object is imported. */ if (definition - && (POINTER_TYPE_P (gnu_type) || TYPE_FAT_POINTER_P (gnu_type)) + && (POINTER_TYPE_P (gnu_type) || TYPE_IS_FAT_POINTER_P (gnu_type)) && !Is_Imported (gnat_entity) && !gnu_expr) gnu_expr = integer_zero_node; @@ -1278,10 +1273,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) if (gnu_expr && TREE_CODE (gnu_type) != UNCONSTRAINED_ARRAY_TYPE && !CONTAINS_PLACEHOLDER_P (TYPE_SIZE (gnu_type)) - && !(TREE_CODE (gnu_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_type) - && (CONTAINS_PLACEHOLDER_P - (TYPE_SIZE (TREE_TYPE (TYPE_FIELDS (gnu_type))))))) + && !(TYPE_IS_PADDING_P (gnu_type) + && CONTAINS_PLACEHOLDER_P + (TYPE_SIZE (TREE_TYPE (TYPE_FIELDS (gnu_type)))))) gnu_expr = convert (gnu_type, gnu_expr); /* If this name is external or there was a name specified, use it, @@ -1303,8 +1297,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) && gnu_expr && TREE_CONSTANT (gnu_expr) && AGGREGATE_TYPE_P (gnu_type) && host_integerp (TYPE_SIZE_UNIT (gnu_type), 1) - && !(TREE_CODE (gnu_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_type) + && !(TYPE_IS_PADDING_P (gnu_type) && !host_integerp (TYPE_SIZE_UNIT (TREE_TYPE (TYPE_FIELDS (gnu_type))), 1))) static_p = true; @@ -1686,7 +1679,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) gnu_field_type, gnu_type, 1, 0, 0, 0); finish_record_type (gnu_type, gnu_field, 0, false); - TYPE_IS_PADDING_P (gnu_type) = 1; + TYPE_PADDING_P (gnu_type) = 1; relate_alias_sets (gnu_type, gnu_field_type, ALIAS_SET_COPY); } @@ -1834,7 +1827,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) /* Do not finalize this record type since the types of its fields are still incomplete at this point. */ finish_record_type (gnu_fat_type, tem, 0, true); - TYPE_IS_FAT_POINTER_P (gnu_fat_type) = 1; + TYPE_FAT_POINTER_P (gnu_fat_type) = 1; /* Build a reference to the template from a PLACEHOLDER_EXPR that is the fat pointer. This will be used to access the individual @@ -2476,7 +2469,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) gnu_inner = gnu_type; while (TREE_CODE (gnu_inner) == RECORD_TYPE && (TYPE_JUSTIFIED_MODULAR_P (gnu_inner) - || TYPE_IS_PADDING_P (gnu_inner))) + || TYPE_PADDING_P (gnu_inner))) gnu_inner = TREE_TYPE (TYPE_FIELDS (gnu_inner)); /* We need to attach the index type to the type we just made so @@ -2985,8 +2978,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) copy_and_substitute_in_size (gnu_type, gnu_base_type, gnu_subst_list); - if (TREE_CODE (gnu_base_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_base_type)) + if (TYPE_IS_PADDING_P (gnu_base_type)) gnu_unpad_base_type = TREE_TYPE (TYPE_FIELDS (gnu_base_type)); else gnu_unpad_base_type = gnu_base_type; @@ -3096,7 +3088,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) { gnu_size = DECL_SIZE (gnu_old_field); if (TREE_CODE (gnu_field_type) == RECORD_TYPE - && !TYPE_IS_FAT_POINTER_P (gnu_field_type) + && !TYPE_FAT_POINTER_P (gnu_field_type) && host_integerp (TYPE_SIZE (gnu_field_type), 1)) gnu_field_type = make_packable_type (gnu_field_type, true); @@ -3464,7 +3456,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) /* Make sure we can place this into a register. */ TYPE_ALIGN (gnu_type) = MIN (BIGGEST_ALIGNMENT, 2 * POINTER_SIZE); - TYPE_IS_FAT_POINTER_P (gnu_type) = 1; + TYPE_FAT_POINTER_P (gnu_type) = 1; /* Do not finalize this record type since the types of its fields are incomplete. */ @@ -3598,11 +3590,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) if ((! in_main_unit || is_from_limited_with) && made_dummy) { tree gnu_old_type - = TYPE_FAT_POINTER_P (gnu_type) + = TYPE_IS_FAT_POINTER_P (gnu_type) ? TYPE_UNCONSTRAINED_ARRAY (gnu_type) : TREE_TYPE (gnu_type); if (esize == POINTER_SIZE - && (got_fat_p || TYPE_FAT_POINTER_P (gnu_type))) + && (got_fat_p || TYPE_IS_FAT_POINTER_P (gnu_type))) gnu_type = build_pointer_type (TYPE_OBJECT_RECORD_TYPE @@ -3914,8 +3906,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) /* If the type is a padded type and the underlying type would not be passed by reference or this function has a foreign convention, return the underlying type. */ - else if (TREE_CODE (gnu_return_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_return_type) + else if (TYPE_IS_PADDING_P (gnu_return_type) && (!default_pass_by_ref (TREE_TYPE (TYPE_FIELDS (gnu_return_type))) || Has_Foreign_Convention (gnat_entity))) @@ -4053,7 +4044,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) between two calls, so they can't be CSE'ed. The latter case also handles by-ref parameters. */ if (POINTER_TYPE_P (gnu_param_type) - || TYPE_FAT_POINTER_P (gnu_param_type)) + || TYPE_IS_FAT_POINTER_P (gnu_param_type)) const_flag = false; } @@ -4416,7 +4407,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) else if ((TREE_CODE (gnu_type) == RECORD_TYPE || TREE_CODE (gnu_type) == UNION_TYPE || TREE_CODE (gnu_type) == QUAL_UNION_TYPE) - && !TYPE_IS_FAT_POINTER_P (gnu_type)) + && !TYPE_FAT_POINTER_P (gnu_type)) size = rm_size (gnu_type); else size = TYPE_SIZE (gnu_type); @@ -4447,8 +4438,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) gnu_type = maybe_pad_type (gnu_type, gnu_size, align, gnat_entity, false, true, definition, false); - if (TREE_CODE (gnu_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_type)) + if (TYPE_IS_PADDING_P (gnu_type)) { gnu_entity_name = TYPE_NAME (gnu_type); if (TREE_CODE (gnu_entity_name) == TYPE_DECL) @@ -4704,8 +4694,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition) tree gnu_low_bound, gnu_high_bound; /* If this is a padded type, we need to use the underlying type. */ - if (TREE_CODE (gnu_scalar_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_scalar_type)) + if (TYPE_IS_PADDING_P (gnu_scalar_type)) gnu_scalar_type = TREE_TYPE (TYPE_FIELDS (gnu_scalar_type)); /* If this is a floating point type and we haven't set a floating @@ -4851,7 +4840,7 @@ get_unpadded_type (Entity_Id gnat_entity) { tree type = gnat_to_gnu_type (gnat_entity); - if (TREE_CODE (type) == RECORD_TYPE && TYPE_IS_PADDING_P (type)) + if (TYPE_IS_PADDING_P (type)) type = TREE_TYPE (TYPE_FIELDS (type)); return type; @@ -4984,7 +4973,7 @@ gnat_to_gnu_component_type (Entity_Id gnat_array, bool definition, && !Has_Aliased_Components (gnat_array) && !Strict_Alignment (Component_Type (gnat_array)) && TREE_CODE (gnu_type) == RECORD_TYPE - && !TYPE_IS_FAT_POINTER_P (gnu_type) + && !TYPE_FAT_POINTER_P (gnu_type) && host_integerp (TYPE_SIZE (gnu_type), 1)) gnu_type = make_packable_type (gnu_type, false); @@ -5088,8 +5077,7 @@ gnat_to_gnu_param (Entity_Id gnat_param, Mechanism_Type mech, /* If this is either a foreign function or if the underlying type won't be passed by reference, strip off possible padding type. */ - if (TREE_CODE (gnu_param_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_param_type)) + if (TYPE_IS_PADDING_P (gnu_param_type)) { tree unpadded_type = TREE_TYPE (TYPE_FIELDS (gnu_param_type)); @@ -5161,7 +5149,7 @@ gnat_to_gnu_param (Entity_Id gnat_param, Mechanism_Type mech, } /* Fat pointers are passed as thin pointers for foreign conventions. */ - else if (foreign && TYPE_FAT_POINTER_P (gnu_param_type)) + else if (foreign && TYPE_IS_FAT_POINTER_P (gnu_param_type)) gnu_param_type = make_type_from_size (gnu_param_type, size_int (POINTER_SIZE), 0); @@ -5462,7 +5450,7 @@ relate_alias_sets (tree gnu_new_type, tree gnu_old_type, enum alias_set_op op) see the inner types. */ while (TREE_CODE (gnu_old_type) == RECORD_TYPE && (TYPE_JUSTIFIED_MODULAR_P (gnu_old_type) - || TYPE_IS_PADDING_P (gnu_old_type))) + || TYPE_PADDING_P (gnu_old_type))) gnu_old_type = TREE_TYPE (TYPE_FIELDS (gnu_old_type)); /* Unconstrained array types are deemed incomplete and would thus be given @@ -5928,7 +5916,7 @@ make_packable_type (tree type, bool in_record) TYPE_JUSTIFIED_MODULAR_P (new_type) = TYPE_JUSTIFIED_MODULAR_P (type); TYPE_CONTAINS_TEMPLATE_P (new_type) = TYPE_CONTAINS_TEMPLATE_P (type); if (TREE_CODE (type) == RECORD_TYPE) - TYPE_IS_PADDING_P (new_type) = TYPE_IS_PADDING_P (type); + TYPE_PADDING_P (new_type) = TYPE_PADDING_P (type); /* If we are in a record and have a small size, set the alignment to try for an integral mode. Otherwise set it to try for a smaller @@ -5971,7 +5959,7 @@ make_packable_type (tree type, bool in_record) if ((TREE_CODE (new_field_type) == RECORD_TYPE || TREE_CODE (new_field_type) == UNION_TYPE || TREE_CODE (new_field_type) == QUAL_UNION_TYPE) - && !TYPE_IS_FAT_POINTER_P (new_field_type) + && !TYPE_FAT_POINTER_P (new_field_type) && host_integerp (TYPE_SIZE (new_field_type), 1)) new_field_type = make_packable_type (new_field_type, true); @@ -5983,7 +5971,7 @@ make_packable_type (tree type, bool in_record) && (TREE_CODE (new_field_type) == RECORD_TYPE || TREE_CODE (new_field_type) == UNION_TYPE || TREE_CODE (new_field_type) == QUAL_UNION_TYPE) - && !TYPE_IS_FAT_POINTER_P (new_field_type) + && !TYPE_FAT_POINTER_P (new_field_type) && !TYPE_CONTAINS_TEMPLATE_P (new_field_type) && TYPE_ADA_SIZE (new_field_type)) new_size = TYPE_ADA_SIZE (new_field_type); @@ -6012,8 +6000,7 @@ make_packable_type (tree type, bool in_record) /* If this is a padding record, we never want to make the size smaller than what was specified. For QUAL_UNION_TYPE, also copy the size. */ - if ((TREE_CODE (type) == RECORD_TYPE && TYPE_IS_PADDING_P (type)) - || TREE_CODE (type) == QUAL_UNION_TYPE) + if (TYPE_IS_PADDING_P (type) || TREE_CODE (type) == QUAL_UNION_TYPE) { TYPE_SIZE (new_type) = TYPE_SIZE (type); TYPE_SIZE_UNIT (new_type) = TYPE_SIZE_UNIT (type); @@ -6066,7 +6053,7 @@ maybe_pad_type (tree type, tree size, unsigned int align, off the padding, since we will either be returning the inner type or repadding it. If no size or alignment is specified, use that of the original padded type. */ - if (TREE_CODE (type) == RECORD_TYPE && TYPE_IS_PADDING_P (type)) + if (TYPE_IS_PADDING_P (type)) { if ((!size || operand_equal_p (round_up (size, @@ -6115,7 +6102,7 @@ maybe_pad_type (tree type, tree size, unsigned int align, generate incorrect debugging information. So make a new record type and name. */ record = make_node (RECORD_TYPE); - TYPE_IS_PADDING_P (record) = 1; + TYPE_PADDING_P (record) = 1; if (Present (gnat_entity)) TYPE_NAME (record) = create_concat_name (gnat_entity, "PAD"); @@ -6438,7 +6425,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed, from a component clause. */ if (TREE_CODE (gnu_field_type) == RECORD_TYPE - && !TYPE_IS_FAT_POINTER_P (gnu_field_type) + && !TYPE_FAT_POINTER_P (gnu_field_type) && host_integerp (TYPE_SIZE (gnu_field_type), 1) && (packed == 1 || (gnu_size @@ -6668,8 +6655,7 @@ is_variable_size (tree type) if (!TREE_CONSTANT (TYPE_SIZE (type))) return true; - if (TREE_CODE (type) == RECORD_TYPE - && TYPE_IS_PADDING_P (type) + if (TYPE_IS_PADDING_P (type) && !TREE_CONSTANT (DECL_SIZE (TYPE_FIELDS (type)))) return true; @@ -7218,7 +7204,7 @@ annotate_object (Entity_Id gnat_entity, tree gnu_type, tree size, bool by_ref) { if (by_ref) { - if (TYPE_FAT_POINTER_P (gnu_type)) + if (TYPE_IS_FAT_POINTER_P (gnu_type)) gnu_type = TYPE_UNCONSTRAINED_ARRAY (gnu_type); else gnu_type = TREE_TYPE (gnu_type); @@ -7533,7 +7519,7 @@ validate_size (Uint uint_size, tree gnu_type, Entity_Id gnat_object, /* If this is an access type or a fat pointer, the minimum size is that given by the smallest integral mode that's valid for pointers. */ - if ((TREE_CODE (gnu_type) == POINTER_TYPE) || TYPE_FAT_POINTER_P (gnu_type)) + if (TREE_CODE (gnu_type) == POINTER_TYPE || TYPE_IS_FAT_POINTER_P (gnu_type)) { enum machine_mode p_mode; @@ -7627,8 +7613,7 @@ set_rm_size (Uint uint_size, tree gnu_type, Entity_Id gnat_entity) || (AGGREGATE_TYPE_P (gnu_type) && !(TREE_CODE (gnu_type) == ARRAY_TYPE && TYPE_PACKED_ARRAY_TYPE_P (gnu_type)) - && !(TREE_CODE (gnu_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_type) + && !(TYPE_IS_PADDING_P (gnu_type) && TREE_CODE (TREE_TYPE (TYPE_FIELDS (gnu_type))) == ARRAY_TYPE && TYPE_PACKED_ARRAY_TYPE_P (TREE_TYPE (TYPE_FIELDS (gnu_type)))) && tree_int_cst_lt (size, old_size))) @@ -7651,7 +7636,7 @@ set_rm_size (Uint uint_size, tree gnu_type, Entity_Id gnat_entity) else if ((TREE_CODE (gnu_type) == RECORD_TYPE || TREE_CODE (gnu_type) == UNION_TYPE || TREE_CODE (gnu_type) == QUAL_UNION_TYPE) - && !TYPE_IS_FAT_POINTER_P (gnu_type)) + && !TYPE_FAT_POINTER_P (gnu_type)) SET_TYPE_ADA_SIZE (gnu_type, size); } @@ -7718,7 +7703,7 @@ make_type_from_size (tree type, tree size_tree, bool for_biased) case RECORD_TYPE: /* Do something if this is a fat pointer, in which case we may need to return the thin pointer. */ - if (TYPE_IS_FAT_POINTER_P (type) && size < POINTER_SIZE * 2) + if (TYPE_FAT_POINTER_P (type) && size < POINTER_SIZE * 2) { enum machine_mode p_mode = mode_for_size (size, MODE_INT, 0); if (!targetm.valid_pointer_mode (p_mode)) @@ -7733,7 +7718,7 @@ make_type_from_size (tree type, tree size_tree, bool for_biased) case POINTER_TYPE: /* Only do something if this is a thin pointer, in which case we may need to return the fat pointer. */ - if (TYPE_THIN_POINTER_P (type) && size >= POINTER_SIZE * 2) + if (TYPE_IS_THIN_POINTER_P (type) && size >= POINTER_SIZE * 2) return build_pointer_type (TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (type))); break; @@ -8384,7 +8369,7 @@ rm_size (tree gnu_type) if ((TREE_CODE (gnu_type) == RECORD_TYPE || TREE_CODE (gnu_type) == UNION_TYPE || TREE_CODE (gnu_type) == QUAL_UNION_TYPE) - && !TYPE_IS_FAT_POINTER_P (gnu_type) + && !TYPE_FAT_POINTER_P (gnu_type) && TYPE_ADA_SIZE (gnu_type)) return TYPE_ADA_SIZE (gnu_type); diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 67823789ab3..570bd111a95 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -527,7 +527,7 @@ gnat_print_type (FILE *file, tree node, int indent) break; case RECORD_TYPE: - if (TYPE_IS_FAT_POINTER_P (node) || TYPE_CONTAINS_TEMPLATE_P (node)) + if (TYPE_FAT_POINTER_P (node) || TYPE_CONTAINS_TEMPLATE_P (node)) print_node (file, "unconstrained array", TYPE_UNCONSTRAINED_ARRAY (node), indent + 4); else @@ -600,8 +600,7 @@ static alias_set_type gnat_get_alias_set (tree type) { /* If this is a padding type, use the type of the first field. */ - if (TREE_CODE (type) == RECORD_TYPE - && TYPE_IS_PADDING_P (type)) + if (TYPE_IS_PADDING_P (type)) return get_alias_set (TREE_TYPE (TYPE_FIELDS (type))); /* If the type is an unconstrained array, use the type of the diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index 74aa2b67ef4..ffcc72aac0f 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -946,8 +946,7 @@ Identifier_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p) || Is_Constr_Subt_For_UN_Aliased (gnat_temp_type)) { gnu_result_type = TREE_TYPE (gnu_result); - if (TREE_CODE (gnu_result_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_result_type)) + if (TYPE_IS_PADDING_P (gnu_result_type)) gnu_result_type = TREE_TYPE (TYPE_FIELDS (gnu_result_type)); } @@ -1256,7 +1255,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) /* If this is an unconstrained array, we know the object has been allocated with the template in front of the object. So compute the template address. */ - if (TYPE_FAT_POINTER_P (TREE_TYPE (gnu_ptr))) + if (TYPE_IS_FAT_POINTER_P (TREE_TYPE (gnu_ptr))) gnu_ptr = convert (build_pointer_type (TYPE_OBJECT_RECORD_TYPE @@ -1334,8 +1333,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) of the relevant field. Using the MAX of those two produces the right result in all case. Don't use the size of the field if it's a self-referential type, since that's never what's wanted. */ - if (TREE_CODE (gnu_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_type) + if (TYPE_IS_PADDING_P (gnu_type) && TREE_CODE (gnu_expr) == COMPONENT_REF) { gnu_result = rm_size (gnu_type); @@ -1353,7 +1351,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) tree gnu_ptr_type = TREE_TYPE (gnat_to_gnu (Prefix (gnat_deref))); - if (TYPE_FAT_OR_THIN_POINTER_P (gnu_ptr_type) + if (TYPE_IS_FAT_OR_THIN_POINTER_P (gnu_ptr_type) && Present (gnat_actual_subtype)) { tree gnu_actual_obj_type @@ -1403,9 +1401,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) unsigned int align; if (TREE_CODE (gnu_prefix) == COMPONENT_REF - && (TREE_CODE (TREE_TYPE (TREE_OPERAND (gnu_prefix, 0))) - == RECORD_TYPE) - && (TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (gnu_prefix, 0))))) + && TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (gnu_prefix, 0)))) gnu_prefix = TREE_OPERAND (gnu_prefix, 0); gnu_type = TREE_TYPE (gnu_prefix); @@ -1742,9 +1738,7 @@ Attribute_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, int attribute) case Attr_Component_Size: if (TREE_CODE (gnu_prefix) == COMPONENT_REF - && (TREE_CODE (TREE_TYPE (TREE_OPERAND (gnu_prefix, 0))) - == RECORD_TYPE) - && (TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (gnu_prefix, 0))))) + && TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (gnu_prefix, 0)))) gnu_prefix = TREE_OPERAND (gnu_prefix, 0); gnu_prefix = maybe_implicit_deref (gnu_prefix); @@ -2562,10 +2556,8 @@ call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target) /* Otherwise remove unpadding from the object and reset the copy. */ else if (TREE_CODE (gnu_name) == COMPONENT_REF - && ((TREE_CODE (TREE_TYPE (TREE_OPERAND (gnu_name, 0))) - == RECORD_TYPE) - && (TYPE_IS_PADDING_P - (TREE_TYPE (TREE_OPERAND (gnu_name, 0)))))) + && TYPE_IS_PADDING_P + (TREE_TYPE (TREE_OPERAND (gnu_name, 0)))) gnu_name = gnu_copy = TREE_OPERAND (gnu_name, 0); /* Otherwise convert to the nominal type of the object if it's @@ -2604,7 +2596,6 @@ call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target) /* If this was a procedure call, we may not have removed any padding. So do it here for the part we will use as an input, if any. */ if (Ekind (gnat_formal) != E_Out_Parameter - && TREE_CODE (TREE_TYPE (gnu_actual)) == RECORD_TYPE && TYPE_IS_PADDING_P (TREE_TYPE (gnu_actual))) gnu_actual = convert (get_unpadded_type (Etype (gnat_actual)), gnu_actual); @@ -2674,8 +2665,7 @@ call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target) gnu_actual = gnu_name; /* If we have a padded type, be sure we've removed padding. */ - if (TREE_CODE (TREE_TYPE (gnu_actual)) == RECORD_TYPE - && TYPE_IS_PADDING_P (TREE_TYPE (gnu_actual)) + if (TYPE_IS_PADDING_P (TREE_TYPE (gnu_actual)) && TREE_CODE (gnu_actual) != SAVE_EXPR) gnu_actual = convert (get_unpadded_type (Etype (gnat_actual)), gnu_actual); @@ -2708,8 +2698,7 @@ call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target) gnu_actual = maybe_implicit_deref (gnu_actual); gnu_actual = maybe_unconstrained_array (gnu_actual); - if (TREE_CODE (gnu_formal_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (gnu_formal_type)) + if (TYPE_IS_PADDING_P (gnu_formal_type)) { gnu_formal_type = TREE_TYPE (TYPE_FIELDS (gnu_formal_type)); gnu_actual = convert (gnu_formal_type, gnu_actual); @@ -2901,8 +2890,7 @@ call_to_gnu (Node_Id gnat_node, tree *gnu_result_type_p, tree gnu_target) = maybe_unconstrained_array (TREE_VALUE (gnu_name_list)); /* If the result is a padded type, remove the padding. */ - if (TREE_CODE (TREE_TYPE (gnu_result)) == RECORD_TYPE - && TYPE_IS_PADDING_P (TREE_TYPE (gnu_result))) + if (TYPE_IS_PADDING_P (TREE_TYPE (gnu_result))) gnu_result = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_result))), gnu_result); @@ -3861,8 +3849,7 @@ gnat_to_gnu (Node_Id gnat_node) gnu_array_object = maybe_unconstrained_array (gnu_array_object); /* If we got a padded type, remove it too. */ - if (TREE_CODE (TREE_TYPE (gnu_array_object)) == RECORD_TYPE - && TYPE_IS_PADDING_P (TREE_TYPE (gnu_array_object))) + if (TYPE_IS_PADDING_P (TREE_TYPE (gnu_array_object))) gnu_array_object = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_array_object))), gnu_array_object); @@ -4718,12 +4705,10 @@ gnat_to_gnu (Node_Id gnat_node) type is self-referential since we want to allocate the fixed size in that case. */ if (TREE_CODE (gnu_ret_val) == COMPONENT_REF - && (TREE_CODE (TREE_TYPE (TREE_OPERAND (gnu_ret_val, 0))) - == RECORD_TYPE) - && (TYPE_IS_PADDING_P - (TREE_TYPE (TREE_OPERAND (gnu_ret_val, 0)))) - && (CONTAINS_PLACEHOLDER_P - (TYPE_SIZE (TREE_TYPE (gnu_ret_val))))) + && TYPE_IS_PADDING_P + (TREE_TYPE (TREE_OPERAND (gnu_ret_val, 0))) + && CONTAINS_PLACEHOLDER_P + (TYPE_SIZE (TREE_TYPE (gnu_ret_val)))) gnu_ret_val = TREE_OPERAND (gnu_ret_val, 0); if (TYPE_RETURNS_BY_REF_P (gnu_subprog_type) @@ -5156,7 +5141,7 @@ gnat_to_gnu (Node_Id gnat_node) a fat pointer, then go back below to a thin pointer. The reason for this is that we need a fat pointer someplace in order to properly compute the size. */ - if (TYPE_THIN_POINTER_P (TREE_TYPE (gnu_ptr))) + if (TYPE_IS_THIN_POINTER_P (TREE_TYPE (gnu_ptr))) gnu_ptr = build_unary_op (ADDR_EXPR, NULL_TREE, build_unary_op (INDIRECT_REF, NULL_TREE, gnu_ptr)); @@ -5165,7 +5150,7 @@ gnat_to_gnu (Node_Id gnat_node) have been allocated with the template in front of the object. So pass the template address, but get the total size. Do this by converting to a thin pointer. */ - if (TYPE_FAT_POINTER_P (TREE_TYPE (gnu_ptr))) + if (TYPE_IS_FAT_POINTER_P (TREE_TYPE (gnu_ptr))) gnu_ptr = convert (build_pointer_type (TYPE_OBJECT_RECORD_TYPE @@ -5179,7 +5164,7 @@ gnat_to_gnu (Node_Id gnat_node) gnu_actual_obj_type = gnat_to_gnu_type (Actual_Designated_Subtype (gnat_node)); - if (TYPE_FAT_OR_THIN_POINTER_P (gnu_ptr_type)) + if (TYPE_IS_FAT_OR_THIN_POINTER_P (gnu_ptr_type)) gnu_actual_obj_type = build_unc_object_type_from_ptr (gnu_ptr_type, gnu_actual_obj_type, @@ -5291,10 +5276,10 @@ gnat_to_gnu (Node_Id gnat_node) /* But if the result is a fat pointer type, we have no mechanism to do that, so we unconditionally warn in problematic cases. */ - else if (TYPE_FAT_POINTER_P (gnu_target_type)) + else if (TYPE_IS_FAT_POINTER_P (gnu_target_type)) { tree gnu_source_array_type - = TYPE_FAT_POINTER_P (gnu_source_type) + = TYPE_IS_FAT_POINTER_P (gnu_source_type) ? TREE_TYPE (TREE_TYPE (TYPE_FIELDS (gnu_source_type))) : NULL_TREE; tree gnu_target_array_type @@ -5302,7 +5287,7 @@ gnat_to_gnu (Node_Id gnat_node) if ((TYPE_DUMMY_P (gnu_target_array_type) || get_alias_set (gnu_target_array_type) != 0) - && (!TYPE_FAT_POINTER_P (gnu_source_type) + && (!TYPE_IS_FAT_POINTER_P (gnu_source_type) || (TYPE_DUMMY_P (gnu_source_array_type) != TYPE_DUMMY_P (gnu_target_array_type)) || (TYPE_DUMMY_P (gnu_source_array_type) @@ -5443,8 +5428,7 @@ gnat_to_gnu (Node_Id gnat_node) size: in that case it must be an object of unconstrained type with a default discriminant and we want to avoid copying too much data. */ - if (TREE_CODE (TREE_TYPE (gnu_result)) == RECORD_TYPE - && TYPE_IS_PADDING_P (TREE_TYPE (gnu_result)) + if (TYPE_IS_PADDING_P (TREE_TYPE (gnu_result)) && CONTAINS_PLACEHOLDER_P (TYPE_SIZE (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_result)))))) gnu_result = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_result))), @@ -5464,8 +5448,7 @@ gnat_to_gnu (Node_Id gnat_node) && TREE_CODE (TREE_TYPE (gnu_result)) == RECORD_TYPE)) { /* Remove any padding. */ - if (TREE_CODE (TREE_TYPE (gnu_result)) == RECORD_TYPE - && TYPE_IS_PADDING_P (TREE_TYPE (gnu_result))) + if (TYPE_IS_PADDING_P (TREE_TYPE (gnu_result))) gnu_result = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (gnu_result))), gnu_result); } @@ -5607,7 +5590,7 @@ add_decl_expr (tree gnu_decl, Entity_Id gnat_entity) { /* If GNU_DECL has a padded type, convert it to the unpadded type so the assignment is done properly. */ - if (TREE_CODE (type) == RECORD_TYPE && TYPE_IS_PADDING_P (type)) + if (TYPE_IS_PADDING_P (type)) t = convert (TREE_TYPE (TYPE_FIELDS (type)), gnu_decl); else t = gnu_decl; @@ -6791,8 +6774,7 @@ convert_with_check (Entity_Id gnat_type, tree gnu_expr, bool overflowp, = FP_ARITH_MAY_WIDEN ? longest_float_type_node : gnu_in_basetype; /* FIXME: Should not have padding in the first place. */ - if (TREE_CODE (calc_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (calc_type)) + if (TYPE_IS_PADDING_P (calc_type)) calc_type = TREE_TYPE (TYPE_FIELDS (calc_type)); /* Compute the exact value calc_type'Pred (0.5) at compile time. */ @@ -6989,7 +6971,7 @@ addressable_p (tree gnu_expr, tree gnu_type) || DECL_ALIGN (TREE_OPERAND (gnu_expr, 1)) >= TYPE_ALIGN (TREE_TYPE (gnu_expr)))) /* The field of a padding record is always addressable. */ - || TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (gnu_expr, 0)))) + || TYPE_PADDING_P (TREE_TYPE (TREE_OPERAND (gnu_expr, 0)))) && addressable_p (TREE_OPERAND (gnu_expr, 0), NULL_TREE)); case ARRAY_REF: case ARRAY_RANGE_REF: @@ -7269,13 +7251,12 @@ static tree maybe_implicit_deref (tree exp) { /* If the type is a pointer, dereference it. */ - - if (POINTER_TYPE_P (TREE_TYPE (exp)) || TYPE_FAT_POINTER_P (TREE_TYPE (exp))) + if (POINTER_TYPE_P (TREE_TYPE (exp)) + || TYPE_IS_FAT_POINTER_P (TREE_TYPE (exp))) exp = build_unary_op (INDIRECT_REF, NULL_TREE, exp); /* If we got a padded type, remove it too. */ - if (TREE_CODE (TREE_TYPE (exp)) == RECORD_TYPE - && TYPE_IS_PADDING_P (TREE_TYPE (exp))) + if (TYPE_IS_PADDING_P (TREE_TYPE (exp))) exp = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (exp))), exp); return exp; @@ -7313,7 +7294,7 @@ protect_multiple_eval (tree exp) /* If this is a fat pointer or something that can be placed into a register, just make a SAVE_EXPR. */ - if (TYPE_FAT_POINTER_P (type) || TYPE_MODE (type) != BLKmode) + if (TYPE_IS_FAT_POINTER_P (type) || TYPE_MODE (type) != BLKmode) return save_expr (exp); /* Otherwise, reference, protect the address and dereference. */ @@ -7498,7 +7479,7 @@ gnat_stabilize_reference_1 (tree e, bool force) fat pointer. This may be more efficient, but will also allow us to more easily find the match for the PLACEHOLDER_EXPR. */ if (code == COMPONENT_REF - && TYPE_FAT_POINTER_P (TREE_TYPE (TREE_OPERAND (e, 0)))) + && TYPE_IS_FAT_POINTER_P (TREE_TYPE (TREE_OPERAND (e, 0)))) result = build3 (COMPONENT_REF, type, gnat_stabilize_reference_1 (TREE_OPERAND (e, 0), force), diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index f1a4b0065ba..86575b529d9 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -490,7 +490,7 @@ gnat_pushdecl (tree decl, Node_Id gnat_node) if (!(TYPE_NAME (t) && TREE_CODE (TYPE_NAME (t)) == TYPE_DECL)) ; - else if (TYPE_FAT_POINTER_P (t)) + else if (TYPE_IS_FAT_POINTER_P (t)) { tree tt = build_variant_type_copy (t); TYPE_NAME (tt) = decl; @@ -643,7 +643,7 @@ finish_record_type (tree record_type, tree fieldlist, int rep_level, if ((TREE_CODE (type) == RECORD_TYPE || TREE_CODE (type) == UNION_TYPE || TREE_CODE (type) == QUAL_UNION_TYPE) - && !TYPE_IS_FAT_POINTER_P (type) + && !TYPE_FAT_POINTER_P (type) && !TYPE_CONTAINS_TEMPLATE_P (type) && TYPE_ADA_SIZE (type)) this_ada_size = TYPE_ADA_SIZE (type); @@ -743,12 +743,11 @@ finish_record_type (tree record_type, tree fieldlist, int rep_level, { /* If this is a padding record, we never want to make the size smaller than what was specified in it, if any. */ - if (TREE_CODE (record_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (record_type) && TYPE_SIZE (record_type)) + if (TYPE_IS_PADDING_P (record_type) && TYPE_SIZE (record_type)) size = TYPE_SIZE (record_type); /* Now set any of the values we've just computed that apply. */ - if (!TYPE_IS_FAT_POINTER_P (record_type) + if (!TYPE_FAT_POINTER_P (record_type) && !TYPE_CONTAINS_TEMPLATE_P (record_type)) SET_TYPE_ADA_SIZE (record_type, ada_size); @@ -810,9 +809,7 @@ rest_of_record_type_compilation (tree record_type) that tells the debugger how the record is laid out. See exp_dbug.ads. But don't do this for records that are padding since they confuse GDB. */ - if (var_size - && !(TREE_CODE (record_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (record_type))) + if (var_size && !TYPE_IS_PADDING_P (record_type)) { tree new_record_type = make_node (TREE_CODE (record_type) == QUAL_UNION_TYPE @@ -1301,7 +1298,7 @@ create_type_decl (tree type_name, tree type, struct attrib *attr_list, if (code == UNCONSTRAINED_ARRAY_TYPE || !debug_info_p) DECL_IGNORED_P (type_decl) = 1; else if (code != ENUMERAL_TYPE - && (code != RECORD_TYPE || TYPE_IS_FAT_POINTER_P (type)) + && (code != RECORD_TYPE || TYPE_FAT_POINTER_P (type)) && !((code == POINTER_TYPE || code == REFERENCE_TYPE) && TYPE_IS_DUMMY_P (TREE_TYPE (type))) && !(code == RECORD_TYPE @@ -2286,7 +2283,7 @@ gnat_types_compatible_p (tree t1, tree t2) /* Padding record types are also compatible if they pad the same type and have the same constant size. */ if (code == RECORD_TYPE - && TYPE_IS_PADDING_P (t1) && TYPE_IS_PADDING_P (t2) + && TYPE_PADDING_P (t1) && TYPE_PADDING_P (t2) && TREE_TYPE (TYPE_FIELDS (t1)) == TREE_TYPE (TYPE_FIELDS (t2)) && tree_int_cst_equal (TYPE_SIZE (t1), TYPE_SIZE (t2))) return 1; @@ -2436,7 +2433,7 @@ build_template (tree template_type, tree array_type, tree expr) tree field; while (TREE_CODE (array_type) == RECORD_TYPE - && (TYPE_IS_PADDING_P (array_type) + && (TYPE_PADDING_P (array_type) || TYPE_JUSTIFIED_MODULAR_P (array_type))) array_type = TREE_TYPE (TYPE_FIELDS (array_type)); @@ -3150,7 +3147,7 @@ convert_vms_descriptor64 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog) if (POINTER_TYPE_P (gnu_type)) return convert (gnu_type, gnu_expr64); - else if (TYPE_FAT_POINTER_P (gnu_type)) + else if (TYPE_IS_FAT_POINTER_P (gnu_type)) { tree p_array_type = TREE_TYPE (TYPE_FIELDS (gnu_type)); tree p_bounds_type = TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (gnu_type))); @@ -3299,7 +3296,7 @@ convert_vms_descriptor32 (tree gnu_type, tree gnu_expr, Entity_Id gnat_subprog) if (POINTER_TYPE_P (gnu_type)) return convert (gnu_type, gnu_expr32); - else if (TYPE_FAT_POINTER_P (gnu_type)) + else if (TYPE_IS_FAT_POINTER_P (gnu_type)) { tree p_array_type = TREE_TYPE (TYPE_FIELDS (gnu_type)); tree p_bounds_type = TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (gnu_type))); @@ -3537,10 +3534,10 @@ build_unc_object_type_from_ptr (tree thin_fat_ptr_type, tree object_type, { tree template_type; - gcc_assert (TYPE_FAT_OR_THIN_POINTER_P (thin_fat_ptr_type)); + gcc_assert (TYPE_IS_FAT_OR_THIN_POINTER_P (thin_fat_ptr_type)); template_type - = (TYPE_FAT_POINTER_P (thin_fat_ptr_type) + = (TYPE_IS_FAT_POINTER_P (thin_fat_ptr_type) ? TREE_TYPE (TREE_TYPE (TREE_CHAIN (TYPE_FIELDS (thin_fat_ptr_type)))) : TREE_TYPE (TYPE_FIELDS (TREE_TYPE (thin_fat_ptr_type)))); return build_unc_object_type (template_type, object_type, name); @@ -3636,7 +3633,7 @@ update_pointer_to (tree old_type, tree new_type) /* Now deal with the unconstrained array case. In this case the "pointer" is actually a RECORD_TYPE where both fields are pointers to dummy nodes. Turn them into pointers to the correct types using update_pointer_to. */ - else if (!TYPE_FAT_POINTER_P (ptr)) + else if (!TYPE_IS_FAT_POINTER_P (ptr)) gcc_unreachable (); else @@ -3737,7 +3734,7 @@ convert_to_fat_pointer (tree type, tree expr) NULL_TREE))); /* If EXPR is a thin pointer, make template and data from the record.. */ - else if (TYPE_THIN_POINTER_P (etype)) + else if (TYPE_IS_THIN_POINTER_P (etype)) { tree fields = TYPE_FIELDS (TREE_TYPE (etype)); @@ -3787,7 +3784,7 @@ convert_to_fat_pointer (tree type, tree expr) static tree convert_to_thin_pointer (tree type, tree expr) { - if (!TYPE_FAT_POINTER_P (TREE_TYPE (expr))) + if (!TYPE_IS_FAT_POINTER_P (TREE_TYPE (expr))) expr = convert_to_fat_pointer (TREE_TYPE (TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (type))), expr); @@ -3822,7 +3819,7 @@ convert (tree type, tree expr) as an unchecked conversion. Likewise if one is a mere variant of the other, so we avoid a pointless unpad/repad sequence. */ else if (code == RECORD_TYPE && ecode == RECORD_TYPE - && TYPE_IS_PADDING_P (type) && TYPE_IS_PADDING_P (etype) + && TYPE_PADDING_P (type) && TYPE_PADDING_P (etype) && (!TREE_CONSTANT (TYPE_SIZE (type)) || !TREE_CONSTANT (TYPE_SIZE (etype)) || gnat_types_compatible_p (type, etype) @@ -3832,7 +3829,7 @@ convert (tree type, tree expr) /* If the output type has padding, convert to the inner type and make a constructor to build the record, unless a variable size is involved. */ - else if (code == RECORD_TYPE && TYPE_IS_PADDING_P (type)) + else if (code == RECORD_TYPE && TYPE_PADDING_P (type)) { /* If we previously converted from another type and our type is of variable size, remove the conversion to avoid the need for @@ -3850,7 +3847,6 @@ convert (tree type, tree expr) variable-sized temporaries. Likewise if the padding is a variant of the other, so we avoid a pointless unpad/repad sequence. */ if (TREE_CODE (expr) == COMPONENT_REF - && TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == RECORD_TYPE && TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (expr, 0))) && (!TREE_CONSTANT (TYPE_SIZE (type)) || gnat_types_compatible_p (type, @@ -3893,7 +3889,7 @@ convert (tree type, tree expr) The conditions ordering is arranged to ensure that the output type is not a padding type here, as it is not clear whether the conversion would always be correct if this was to happen. */ - else if (ecode == RECORD_TYPE && TYPE_IS_PADDING_P (etype)) + else if (ecode == RECORD_TYPE && TYPE_PADDING_P (etype)) { tree unpadded; @@ -4142,7 +4138,8 @@ convert (tree type, tree expr) /* Otherwise, we may just bypass the input view conversion unless one of the types is a fat pointer, which is handled by specialized code below which relies on exact type matching. */ - else if (!TYPE_FAT_POINTER_P (type) && !TYPE_FAT_POINTER_P (etype)) + else if (!TYPE_IS_FAT_POINTER_P (type) + && !TYPE_IS_FAT_POINTER_P (etype)) return convert (type, op0); } } @@ -4161,7 +4158,7 @@ convert (tree type, tree expr) || TREE_CODE (type) == UNION_TYPE) && (TREE_CODE (etype) == RECORD_TYPE || TREE_CODE (etype) == UNION_TYPE) - && !TYPE_FAT_POINTER_P (type) && !TYPE_FAT_POINTER_P (etype)) + && !TYPE_IS_FAT_POINTER_P (type) && !TYPE_IS_FAT_POINTER_P (etype)) return build_unary_op (INDIRECT_REF, NULL_TREE, convert (build_pointer_type (type), TREE_OPERAND (expr, 0))); @@ -4172,7 +4169,7 @@ convert (tree type, tree expr) } /* Check for converting to a pointer to an unconstrained array. */ - if (TYPE_FAT_POINTER_P (type) && !TYPE_FAT_POINTER_P (etype)) + if (TYPE_IS_FAT_POINTER_P (type) && !TYPE_IS_FAT_POINTER_P (etype)) return convert_to_fat_pointer (type, expr); /* If we are converting between two aggregate or vector types that are mere @@ -4244,7 +4241,7 @@ convert (tree type, tree expr) /* If converting between two pointers to records denoting both a template and type, adjust if needed to account for any differing offsets, since one might be negative. */ - if (TYPE_THIN_POINTER_P (etype) && TYPE_THIN_POINTER_P (type)) + if (TYPE_IS_THIN_POINTER_P (etype) && TYPE_IS_THIN_POINTER_P (type)) { tree bit_diff = size_diffop (bit_position (TYPE_FIELDS (TREE_TYPE (etype))), @@ -4262,13 +4259,13 @@ convert (tree type, tree expr) } /* If converting to a thin pointer, handle specially. */ - if (TYPE_THIN_POINTER_P (type) + if (TYPE_IS_THIN_POINTER_P (type) && TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (type))) return convert_to_thin_pointer (type, expr); /* If converting fat pointer to normal pointer, get the pointer to the array and then convert it. */ - else if (TYPE_FAT_POINTER_P (etype)) + else if (TYPE_IS_FAT_POINTER_P (etype)) expr = build_component_ref (expr, get_identifier ("P_ARRAY"), NULL_TREE, false); @@ -4365,8 +4362,7 @@ remove_conversions (tree exp, bool true_address) break; case COMPONENT_REF: - if (TREE_CODE (TREE_TYPE (TREE_OPERAND (exp, 0))) == RECORD_TYPE - && TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (exp, 0)))) + if (TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (exp, 0)))) return remove_conversions (TREE_OPERAND (exp, 0), true_address); break; @@ -4415,7 +4411,7 @@ maybe_unconstrained_array (tree exp) case RECORD_TYPE: /* If this is a padded type, convert to the unpadded type and see if it contains a template. */ - if (TYPE_IS_PADDING_P (TREE_TYPE (exp))) + if (TYPE_PADDING_P (TREE_TYPE (exp))) { new_exp = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (exp))), exp); if (TREE_CODE (TREE_TYPE (new_exp)) == RECORD_TYPE @@ -4518,13 +4514,13 @@ unchecked_convert (tree type, tree expr, bool notrunc_p) if ((((INTEGRAL_TYPE_P (type) && !(TREE_CODE (type) == INTEGER_TYPE && TYPE_VAX_FLOATING_POINT_P (type))) - || (POINTER_TYPE_P (type) && ! TYPE_THIN_POINTER_P (type)) + || (POINTER_TYPE_P (type) && ! TYPE_IS_THIN_POINTER_P (type)) || (TREE_CODE (type) == RECORD_TYPE && TYPE_JUSTIFIED_MODULAR_P (type))) && ((INTEGRAL_TYPE_P (etype) && !(TREE_CODE (etype) == INTEGER_TYPE && TYPE_VAX_FLOATING_POINT_P (etype))) - || (POINTER_TYPE_P (etype) && !TYPE_THIN_POINTER_P (etype)) + || (POINTER_TYPE_P (etype) && !TYPE_IS_THIN_POINTER_P (etype)) || (TREE_CODE (etype) == RECORD_TYPE && TYPE_JUSTIFIED_MODULAR_P (etype)))) || TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE) @@ -5504,7 +5500,7 @@ handle_vector_type_attribute (tree *node, tree name, tree ARG_UNUSED (args), /* Get the representative array type, possibly nested within a padding record e.g. for alignment purposes. */ - if (TREE_CODE (rep_type) == RECORD_TYPE && TYPE_IS_PADDING_P (rep_type)) + if (TYPE_IS_PADDING_P (rep_type)) rep_type = TREE_TYPE (TYPE_FIELDS (rep_type)); if (TREE_CODE (rep_type) != ARRAY_TYPE) diff --git a/gcc/ada/gcc-interface/utils2.c b/gcc/ada/gcc-interface/utils2.c index f8a3dfbd525..fcd9ecd1253 100644 --- a/gcc/ada/gcc-interface/utils2.c +++ b/gcc/ada/gcc-interface/utils2.c @@ -654,12 +654,9 @@ build_binary_op (enum tree_code op_code, tree result_type, can convert the constructor to the inner type, to avoid putting a VIEW_CONVERT_EXPR on the LHS. But don't do so if we wouldn't have actually copied anything. */ - else if (TREE_CODE (left_type) == RECORD_TYPE - && TYPE_IS_PADDING_P (left_type) + else if (TYPE_IS_PADDING_P (left_type) && TREE_CONSTANT (TYPE_SIZE (left_type)) && ((TREE_CODE (right_operand) == COMPONENT_REF - && TREE_CODE (TREE_TYPE (TREE_OPERAND (right_operand, 0))) - == RECORD_TYPE && TYPE_IS_PADDING_P (TREE_TYPE (TREE_OPERAND (right_operand, 0))) && gnat_types_compatible_p @@ -836,8 +833,8 @@ build_binary_op (enum tree_code op_code, tree result_type, convert both operands to that type. */ if (left_base_type != right_base_type) { - if (TYPE_FAT_POINTER_P (left_base_type) - && TYPE_FAT_POINTER_P (right_base_type) + if (TYPE_IS_FAT_POINTER_P (left_base_type) + && TYPE_IS_FAT_POINTER_P (right_base_type) && TYPE_MAIN_VARIANT (left_base_type) == TYPE_MAIN_VARIANT (right_base_type)) best_type = left_base_type; @@ -872,7 +869,7 @@ build_binary_op (enum tree_code op_code, tree result_type, /* If we are comparing a fat pointer against zero, we need to just compare the data pointer. */ - else if (TYPE_FAT_POINTER_P (left_base_type) + else if (TYPE_IS_FAT_POINTER_P (left_base_type) && TREE_CODE (right_operand) == CONSTRUCTOR && integer_zerop (VEC_index (constructor_elt, CONSTRUCTOR_ELTS (right_operand), @@ -1117,11 +1114,10 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) /* If INNER is a padding type whose field has a self-referential size, convert to that inner type. We know the offset is zero and we need to have that type visible. */ - if (TREE_CODE (TREE_TYPE (inner)) == RECORD_TYPE - && TYPE_IS_PADDING_P (TREE_TYPE (inner)) - && (CONTAINS_PLACEHOLDER_P - (TYPE_SIZE (TREE_TYPE (TYPE_FIELDS - (TREE_TYPE (inner))))))) + if (TYPE_IS_PADDING_P (TREE_TYPE (inner)) + && CONTAINS_PLACEHOLDER_P + (TYPE_SIZE (TREE_TYPE (TYPE_FIELDS + (TREE_TYPE (inner)))))) inner = convert (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (inner))), inner); @@ -1154,13 +1150,11 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) /* If this is just a constructor for a padded record, we can just take the address of the single field and convert it to a pointer to our type. */ - if (TREE_CODE (type) == RECORD_TYPE && TYPE_IS_PADDING_P (type)) + if (TYPE_IS_PADDING_P (type)) { - result = (VEC_index (constructor_elt, - CONSTRUCTOR_ELTS (operand), - 0) - ->value); - + result = VEC_index (constructor_elt, + CONSTRUCTOR_ELTS (operand), + 0)->value; result = convert (build_pointer_type (TREE_TYPE (operand)), build_unary_op (ADDR_EXPR, NULL_TREE, result)); break; @@ -1202,8 +1196,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) /* If we are taking the address of a padded record whose field is contains a template, take the address of the template. */ - if (TREE_CODE (type) == RECORD_TYPE - && TYPE_IS_PADDING_P (type) + if (TYPE_IS_PADDING_P (type) && TREE_CODE (TREE_TYPE (TYPE_FIELDS (type))) == RECORD_TYPE && TYPE_CONTAINS_TEMPLATE_P (TREE_TYPE (TYPE_FIELDS (type)))) { @@ -1226,7 +1219,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) make up an expression to do so. This will never survive to the backend. If TYPE is a thin pointer, first convert the operand to a fat pointer. */ - if (TYPE_THIN_POINTER_P (type) + if (TYPE_IS_THIN_POINTER_P (type) && TYPE_UNCONSTRAINED_ARRAY (TREE_TYPE (type))) { operand @@ -1235,7 +1228,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) type = TREE_TYPE (operand); } - if (TYPE_FAT_POINTER_P (type)) + if (TYPE_IS_FAT_POINTER_P (type)) { result = build1 (UNCONSTRAINED_ARRAY_REF, TYPE_UNCONSTRAINED_ARRAY (type), operand); @@ -1252,7 +1245,7 @@ build_unary_op (enum tree_code op_code, tree result_type, tree operand) } side_effects - = (!TYPE_FAT_POINTER_P (type) && TYPE_VOLATILE (TREE_TYPE (type))); + = (!TYPE_IS_FAT_POINTER_P (type) && TYPE_VOLATILE (TREE_TYPE (type))); break; case NEGATE_EXPR: @@ -2027,7 +2020,7 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, /* If RESULT_TYPE is a fat or thin pointer, set SIZE to be the sum of the sizes of the object and its template. Allocate the whole thing and fill in the parts that are known. */ - else if (TYPE_FAT_OR_THIN_POINTER_P (result_type)) + else if (TYPE_IS_FAT_OR_THIN_POINTER_P (result_type)) { tree storage_type = build_unc_object_type_from_ptr (result_type, type, @@ -2049,10 +2042,9 @@ build_allocator (tree type, tree init, tree result_type, Entity_Id gnat_proc, gnat_proc, gnat_pool, gnat_node); storage = convert (storage_ptr_type, protect_multiple_eval (storage)); - if (TREE_CODE (type) == RECORD_TYPE && TYPE_IS_PADDING_P (type)) + if (TYPE_IS_PADDING_P (type)) { type = TREE_TYPE (TYPE_FIELDS (type)); - if (init) init = convert (type, init); } -- 2.30.2