diff options
Diffstat (limited to 'gcc/ada/gcc-interface/misc.c')
-rw-r--r-- | gcc/ada/gcc-interface/misc.c | 71 |
1 files changed, 19 insertions, 52 deletions
diff --git a/gcc/ada/gcc-interface/misc.c b/gcc/ada/gcc-interface/misc.c index 623c48e..38e33be 100644 --- a/gcc/ada/gcc-interface/misc.c +++ b/gcc/ada/gcc-interface/misc.c @@ -727,6 +727,10 @@ gnat_get_alias_set (tree type) if (TYPE_IS_PADDING_P (type)) return get_alias_set (TREE_TYPE (TYPE_FIELDS (type))); + /* If this is an extra subtype, use the base type. */ + else if (TYPE_IS_EXTRA_SUBTYPE_P (type)) + return get_alias_set (get_base_type (type)); + /* If the type is an unconstrained array, use the type of the self-referential array we make. */ else if (TREE_CODE (type) == UNCONSTRAINED_ARRAY_TYPE) @@ -753,59 +757,22 @@ gnat_type_max_size (const_tree gnu_type) elaborated and possibly replaced by a VAR_DECL. */ tree max_size_unit = max_size (TYPE_SIZE_UNIT (gnu_type), true); - /* If we don't have a constant, try to look at attributes which should have - stayed untouched. */ - if (!tree_fits_uhwi_p (max_size_unit)) + /* If we don't have a constant, see what we can get from TYPE_ADA_SIZE, + which should stay untouched. */ + if (!tree_fits_uhwi_p (max_size_unit) + && RECORD_OR_UNION_TYPE_P (gnu_type) + && !TYPE_FAT_POINTER_P (gnu_type) + && TYPE_ADA_SIZE (gnu_type)) { - /* For record types, see what we can get from TYPE_ADA_SIZE. */ - if (RECORD_OR_UNION_TYPE_P (gnu_type) - && !TYPE_FAT_POINTER_P (gnu_type) - && TYPE_ADA_SIZE (gnu_type)) - { - tree max_ada_size = max_size (TYPE_ADA_SIZE (gnu_type), true); - - /* If we have succeeded in finding a constant, round it up to the - type's alignment and return the result in units. */ - if (tree_fits_uhwi_p (max_ada_size)) - max_size_unit - = size_binop (CEIL_DIV_EXPR, - round_up (max_ada_size, TYPE_ALIGN (gnu_type)), - bitsize_unit_node); - } - - /* For array types, see what we can get from TYPE_INDEX_TYPE. */ - else if (TREE_CODE (gnu_type) == ARRAY_TYPE - && TYPE_INDEX_TYPE (TYPE_DOMAIN (gnu_type)) - && tree_fits_uhwi_p (TYPE_SIZE_UNIT (TREE_TYPE (gnu_type)))) - { - tree lb = TYPE_MIN_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (gnu_type))); - tree hb = TYPE_MAX_VALUE (TYPE_INDEX_TYPE (TYPE_DOMAIN (gnu_type))); - if (TREE_CODE (lb) != INTEGER_CST - && TYPE_RM_SIZE (TREE_TYPE (lb)) - && compare_tree_int (TYPE_RM_SIZE (TREE_TYPE (lb)), 16) <= 0) - lb = TYPE_MIN_VALUE (TREE_TYPE (lb)); - if (TREE_CODE (hb) != INTEGER_CST - && TYPE_RM_SIZE (TREE_TYPE (hb)) - && compare_tree_int (TYPE_RM_SIZE (TREE_TYPE (hb)), 16) <= 0) - hb = TYPE_MAX_VALUE (TREE_TYPE (hb)); - if (TREE_CODE (lb) == INTEGER_CST && TREE_CODE (hb) == INTEGER_CST) - { - tree ctype = get_base_type (TREE_TYPE (lb)); - lb = fold_convert (ctype, lb); - hb = fold_convert (ctype, hb); - if (tree_int_cst_le (lb, hb)) - { - tree length - = fold_build2 (PLUS_EXPR, ctype, - fold_build2 (MINUS_EXPR, ctype, hb, lb), - build_int_cst (ctype, 1)); - max_size_unit - = fold_build2 (MULT_EXPR, sizetype, - fold_convert (sizetype, length), - TYPE_SIZE_UNIT (TREE_TYPE (gnu_type))); - } - } - } + tree max_ada_size = max_size (TYPE_ADA_SIZE (gnu_type), true); + + /* If we have succeeded in finding a constant, round it up to the + type's alignment and return the result in units. */ + if (tree_fits_uhwi_p (max_ada_size)) + max_size_unit + = size_binop (CEIL_DIV_EXPR, + round_up (max_ada_size, TYPE_ALIGN (gnu_type)), + bitsize_unit_node); } return max_size_unit; |