aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2018-06-12 09:51:26 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2018-06-12 09:51:26 +0000
commitcd8ad45920aaf33a660b85878c572298faba06bf (patch)
tree3c8c32322ff2d79c1acfc7387a1606252f353502 /gcc/ada/gcc-interface/utils.c
parent835d417373cf5843051885e2cba29aea30814606 (diff)
downloadgcc-cd8ad45920aaf33a660b85878c572298faba06bf.zip
gcc-cd8ad45920aaf33a660b85878c572298faba06bf.tar.gz
gcc-cd8ad45920aaf33a660b85878c572298faba06bf.tar.bz2
decl.c (variant_desc): Add AUX field.
* gcc-interface/decl.c (variant_desc): Add AUX field. (gnat_to_gnu_entity) <discrete_type>: Do not call compute_record_mode directly. (reverse_sort_field_list): New static function. (components_to_record): Place the variant part at the beginning of the field list when there is an obvious order of increasing position. (build_variant_list): Initialize it. (create_variant_part_from): Do not call compute_record_mode directly. (copy_and_substitute_in_layout): Likewise. Always sort the fields with fixed position in order of increasing position, in the record and all the variants, in any. Call reverse_sort_field_list. * gcc-interface/utils.c (make_packable_type): Compute the sizes before calling finish_record_type. Do not call compute_record_mode directly. (finish_record_type): Overhaul final processing depending on REP_LEVEL and call finish_bitfield_layout if it is equal to one or two. From-SVN: r261479
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r--gcc/ada/gcc-interface/utils.c51
1 files changed, 28 insertions, 23 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index d415f49..992d568 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -1054,12 +1054,6 @@ make_packable_type (tree type, bool in_record, unsigned int max_align)
new_field_list = new_field;
}
- finish_record_type (new_type, nreverse (new_field_list), 2, false);
- relate_alias_sets (new_type, type, ALIAS_SET_COPY);
- if (TYPE_STUB_DECL (type))
- SET_DECL_PARALLEL_TYPE (TYPE_STUB_DECL (new_type),
- DECL_PARALLEL_TYPE (TYPE_STUB_DECL (type)));
-
/* 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 (TYPE_IS_PADDING_P (type) || TREE_CODE (type) == QUAL_UNION_TYPE)
@@ -1077,7 +1071,11 @@ make_packable_type (tree type, bool in_record, unsigned int max_align)
if (!TYPE_CONTAINS_TEMPLATE_P (type))
SET_TYPE_ADA_SIZE (new_type, TYPE_ADA_SIZE (type));
- compute_record_mode (new_type);
+ finish_record_type (new_type, nreverse (new_field_list), 2, false);
+ relate_alias_sets (new_type, type, ALIAS_SET_COPY);
+ if (TYPE_STUB_DECL (type))
+ SET_DECL_PARALLEL_TYPE (TYPE_STUB_DECL (new_type),
+ DECL_PARALLEL_TYPE (TYPE_STUB_DECL (type)));
/* Try harder to get a packable type if necessary, for example
in case the record itself contains a BLKmode field. */
@@ -1951,33 +1949,40 @@ finish_record_type (tree record_type, tree field_list, int rep_level,
if (code == QUAL_UNION_TYPE)
nreverse (field_list);
- if (rep_level < 2)
+ /* We need to set the regular sizes if REP_LEVEL is one. */
+ if (rep_level == 1)
{
/* If this is a padding record, we never want to make the size smaller
than what was specified in it, if any. */
if (TYPE_IS_PADDING_P (record_type) && TYPE_SIZE (record_type))
size = TYPE_SIZE (record_type);
+ tree size_unit = had_size_unit
+ ? TYPE_SIZE_UNIT (record_type)
+ : convert (sizetype,
+ size_binop (CEIL_DIV_EXPR, size,
+ bitsize_unit_node));
+ const unsigned int align = TYPE_ALIGN (record_type);
+
+ TYPE_SIZE (record_type) = variable_size (round_up (size, align));
+ TYPE_SIZE_UNIT (record_type)
+ = variable_size (round_up (size_unit, align / BITS_PER_UNIT));
+ }
+
+ /* We need to set the Ada size if REP_LEVEL is zero or one. */
+ if (rep_level < 2)
+ {
/* Now set any of the values we've just computed that apply. */
if (!TYPE_FAT_POINTER_P (record_type)
&& !TYPE_CONTAINS_TEMPLATE_P (record_type))
SET_TYPE_ADA_SIZE (record_type, ada_size);
+ }
- if (rep_level > 0)
- {
- tree size_unit = had_size_unit
- ? TYPE_SIZE_UNIT (record_type)
- : convert (sizetype,
- size_binop (CEIL_DIV_EXPR, size,
- bitsize_unit_node));
- unsigned int align = TYPE_ALIGN (record_type);
-
- TYPE_SIZE (record_type) = variable_size (round_up (size, align));
- TYPE_SIZE_UNIT (record_type)
- = variable_size (round_up (size_unit, align / BITS_PER_UNIT));
-
- compute_record_mode (record_type);
- }
+ /* We need to set the mode if REP_LEVEL is one or two. */
+ if (rep_level > 0)
+ {
+ compute_record_mode (record_type);
+ finish_bitfield_layout (record_type);
}
/* Reset the TYPE_MAX_ALIGN field since it's private to gigi. */