diff options
author | Eric Botcazou <ebotcazou@adacore.com> | 2019-06-29 08:10:20 +0000 |
---|---|---|
committer | Eric Botcazou <ebotcazou@gcc.gnu.org> | 2019-06-29 08:10:20 +0000 |
commit | 8623afc48b8125bf7c98f28d913def7f401570ca (patch) | |
tree | 716529cf3ec42c151359f725dc3e5bedfada5f11 /gcc/ada/gcc-interface/utils.c | |
parent | 26cf78991015e0f96f9bc4d771816322e58e56ec (diff) | |
download | gcc-8623afc48b8125bf7c98f28d913def7f401570ca.zip gcc-8623afc48b8125bf7c98f28d913def7f401570ca.tar.gz gcc-8623afc48b8125bf7c98f28d913def7f401570ca.tar.bz2 |
decl.c (gnat_to_gnu_entity): If the type requires strict alignment, then set the RM size to the type size.
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Type>: If the
type requires strict alignment, then set the RM size to the type size.
Rework handling of alignment and sizes of tagged types in ASIS mode.
(validate_size): Rename local variable and remove special handling for
strict-alignment types.
* gcc-interface/utils.c (finish_record_type): Constify local variables
and use properly typed constants.
From-SVN: r272820
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r-- | gcc/ada/gcc-interface/utils.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index c4842b2..9da606e 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -1859,13 +1859,18 @@ void finish_record_type (tree record_type, tree field_list, int rep_level, bool debug_info_p) { - enum tree_code code = TREE_CODE (record_type); + const enum tree_code orig_code = TREE_CODE (record_type); + const bool had_size = TYPE_SIZE (record_type) != NULL_TREE; + const bool had_size_unit = TYPE_SIZE_UNIT (record_type) != NULL_TREE; + const bool had_align = TYPE_ALIGN (record_type) > 0; + /* For all-repped records with a size specified, lay the QUAL_UNION_TYPE + out just like a UNION_TYPE, since the size will be fixed. */ + const enum tree_code code + = (orig_code == QUAL_UNION_TYPE && rep_level > 0 && had_size + ? UNION_TYPE : orig_code); tree name = TYPE_IDENTIFIER (record_type); tree ada_size = bitsize_zero_node; tree size = bitsize_zero_node; - bool had_size = TYPE_SIZE (record_type) != 0; - bool had_size_unit = TYPE_SIZE_UNIT (record_type) != 0; - bool had_align = TYPE_ALIGN (record_type) != 0; tree field; TYPE_FIELDS (record_type) = field_list; @@ -1878,26 +1883,21 @@ finish_record_type (tree record_type, tree field_list, int rep_level, that just means some initializations; otherwise, layout the record. */ if (rep_level > 0) { - SET_TYPE_ALIGN (record_type, MAX (BITS_PER_UNIT, - TYPE_ALIGN (record_type))); - - if (!had_size_unit) - TYPE_SIZE_UNIT (record_type) = size_zero_node; + if (TYPE_ALIGN (record_type) < BITS_PER_UNIT) + SET_TYPE_ALIGN (record_type, BITS_PER_UNIT); if (!had_size) TYPE_SIZE (record_type) = bitsize_zero_node; - /* For all-repped records with a size specified, lay the QUAL_UNION_TYPE - out just like a UNION_TYPE, since the size will be fixed. */ - else if (code == QUAL_UNION_TYPE) - code = UNION_TYPE; + if (!had_size_unit) + TYPE_SIZE_UNIT (record_type) = size_zero_node; } else { /* Ensure there isn't a size already set. There can be in an error case where there is a rep clause but all fields have errors and no longer have a position. */ - TYPE_SIZE (record_type) = 0; + TYPE_SIZE (record_type) = NULL_TREE; /* Ensure we use the traditional GCC layout for bitfields when we need to pack the record type or have a representation clause. The other |