diff options
author | Bob Duff <duff@adacore.com> | 2021-07-02 11:41:28 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-09-21 15:24:57 +0000 |
commit | b23cdc01588b60f52a8c70c8f4465a068b49d317 (patch) | |
tree | 6e4640413b49f9c2a3ede3201136938fca7f5db7 /gcc/ada/gcc-interface/decl.c | |
parent | e9068967876383bf0d9280b4f455fd50e7faf152 (diff) | |
download | gcc-b23cdc01588b60f52a8c70c8f4465a068b49d317.zip gcc-b23cdc01588b60f52a8c70c8f4465a068b49d317.tar.gz gcc-b23cdc01588b60f52a8c70c8f4465a068b49d317.tar.bz2 |
[Ada] Clean up uses of Esize and RM_Size
gcc/ada/
* einfo-utils.adb: Add support (currently disabled) for using
"initial zero" instead of "Uint_0" to represent "unknown". Call
Known_ functions, instead of evilly duplicating their code
inline.
* fe.h (No_Uint_To_0): New function to convert No_Uint to
Uint_0, in order to preserve existing behavior.
(Copy_Esize, Copy_RM_Size): New imports from Einfo.Utils.
* cstand.adb: Set size fields of Standard_Debug_Renaming_Type
and Standard_Exception_Type.
* checks.adb, exp_attr.adb, exp_ch3.adb, exp_ch5.adb,
exp_ch6.adb, exp_pakd.adb, exp_util.adb, freeze.adb, itypes.adb,
layout.adb, repinfo.adb, sem_attr.adb, sem_ch12.adb,
sem_ch13.adb, sem_ch13.ads, sem_ch3.adb, sem_ch7.adb,
sem_util.adb: Protect calls with Known_..., use Copy_... Remove
assumption that Uint_0 represents "unknown".
* types.ads (Nonzero_Int): New subtype.
* gcc-interface/decl.c, gcc-interface/trans.c: Protect calls
with Known_... and use Copy_... as appropriate, to avoid
blowing up in unknown cases. Similarly, call No_Uint_To_0 to
preserve existing behavior.
Diffstat (limited to 'gcc/ada/gcc-interface/decl.c')
-rw-r--r-- | gcc/ada/gcc-interface/decl.c | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index 0120b21..884d1d8 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -4303,7 +4303,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) gnu_size = validate_size (Esize (gnat_entity), gnu_type, gnat_entity, VAR_DECL, false, false, size_s, type_s); - else + + /* ??? The test on Has_Size_Clause must be removed when "unknown" is + no longer represented as Uint_0 (i.e. Use_New_Unknown_Rep). */ + else if (Known_RM_Size (gnat_entity) + || Has_Size_Clause (gnat_entity)) gnu_size = validate_size (RM_Size (gnat_entity), gnu_type, gnat_entity, TYPE_DECL, false, Has_Size_Clause (gnat_entity), @@ -4386,7 +4390,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) /* Now set the RM size of the type. We cannot do it before padding because we need to accept arbitrary RM sizes on integral types. */ - set_rm_size (RM_Size (gnat_entity), gnu_type, gnat_entity); + if (Known_RM_Size (gnat_entity)) + set_rm_size (RM_Size (gnat_entity), gnu_type, gnat_entity); /* Back-annotate the alignment of the type if not already set. */ if (!Known_Alignment (gnat_entity)) @@ -4417,16 +4422,15 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) /* Likewise for the size, if any. */ if (!Known_Esize (gnat_entity) && TYPE_SIZE (gnu_type)) { - tree gnu_size = TYPE_SIZE (gnu_type); + tree size = TYPE_SIZE (gnu_type); /* If the size is self-referential, annotate the maximum value after saturating it, if need be, to avoid a No_Uint value. */ - if (CONTAINS_PLACEHOLDER_P (gnu_size)) + if (CONTAINS_PLACEHOLDER_P (size)) { const unsigned int align = UI_To_Int (Alignment (gnat_entity)) * BITS_PER_UNIT; - gnu_size - = maybe_saturate_size (max_size (gnu_size, true), align); + size = maybe_saturate_size (max_size (size, true), align); } /* If we are just annotating types and the type is tagged, the tag @@ -4464,12 +4468,11 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) if (TYPE_FIELDS (gnu_type)) offset = round_up (offset, DECL_ALIGN (TYPE_FIELDS (gnu_type))); - gnu_size = size_binop (PLUS_EXPR, gnu_size, offset); + size = size_binop (PLUS_EXPR, size, offset); } - gnu_size - = maybe_saturate_size (round_up (gnu_size, align), align); - Set_Esize (gnat_entity, annotate_value (gnu_size)); + size = maybe_saturate_size (round_up (size, align), align); + Set_Esize (gnat_entity, annotate_value (size)); /* Tagged types are Strict_Alignment so RM_Size = Esize. */ if (!Known_RM_Size (gnat_entity)) @@ -4478,12 +4481,13 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) /* Otherwise no adjustment is needed. */ else - Set_Esize (gnat_entity, annotate_value (gnu_size)); + Set_Esize (gnat_entity, No_Uint_To_0 (annotate_value (size))); } /* Likewise for the RM size, if any. */ if (!Known_RM_Size (gnat_entity) && TYPE_SIZE (gnu_type)) - Set_RM_Size (gnat_entity, annotate_value (rm_size (gnu_type))); + Set_RM_Size (gnat_entity, + No_Uint_To_0 (annotate_value (rm_size (gnu_type)))); /* If we are at global level, GCC applied variable_size to the size but this has done nothing. So, if it's not constant or self-referential, @@ -4758,9 +4762,9 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) if (!Known_Alignment (gnat_entity)) Copy_Alignment (gnat_entity, gnat_annotate_type); if (!Known_Esize (gnat_entity)) - Set_Esize (gnat_entity, Esize (gnat_annotate_type)); + Copy_Esize (gnat_entity, gnat_annotate_type); if (!Known_RM_Size (gnat_entity)) - Set_RM_Size (gnat_entity, RM_Size (gnat_annotate_type)); + Copy_RM_Size (gnat_entity, gnat_annotate_type); } /* If we haven't already, associate the ..._DECL node that we just made with @@ -8774,7 +8778,7 @@ annotate_object (Entity_Id gnat_entity, tree gnu_type, tree size, bool by_ref) size = TYPE_SIZE (gnu_type); if (size) - Set_Esize (gnat_entity, annotate_value (size)); + Set_Esize (gnat_entity, No_Uint_To_0 (annotate_value (size))); } if (!Known_Alignment (gnat_entity)) @@ -8880,8 +8884,9 @@ annotate_rep (Entity_Id gnat_entity, tree gnu_type) (gnat_field, annotate_value (bit_from_pos (offset, bit_offset))); - Set_Esize (gnat_field, - annotate_value (DECL_SIZE (TREE_PURPOSE (t)))); + Set_Esize + (gnat_field, + No_Uint_To_0 (annotate_value (DECL_SIZE (TREE_PURPOSE (t))))); } else if (is_extension) { |