aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2019-09-23 07:45:58 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2019-09-23 07:45:58 +0000
commitfdfa0e44b7e5bbf319634a2d51cc7fbfb7aae27a (patch)
tree09718d8d17bacef6c534f67341a5791dbaf4862d /gcc/ada
parent2d814ac2f7b4200c2f47c562bb3b0cfc7b4f2325 (diff)
downloadgcc-fdfa0e44b7e5bbf319634a2d51cc7fbfb7aae27a.zip
gcc-fdfa0e44b7e5bbf319634a2d51cc7fbfb7aae27a.tar.gz
gcc-fdfa0e44b7e5bbf319634a2d51cc7fbfb7aae27a.tar.bz2
decl.c (components_to_record): Do not reorder fields in packed record types if...
* gcc-interface/decl.c (components_to_record): Do not reorder fields in packed record types if they contain fixed-size fields that cannot be laid out in a packed manner. From-SVN: r276036
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/gcc-interface/decl.c15
2 files changed, 17 insertions, 4 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 94b32fb..79e6326 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2019-09-23 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/decl.c (components_to_record): Do not reorder fields
+ in packed record types if they contain fixed-size fields that cannot
+ be laid out in a packed manner.
+
2019-09-19 Tom Tromey <tromey@adacore.com>
* gcc-interface/misc.c (gnat_get_type_bias): Return the bias
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index d1082ee..67b938e 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -7521,6 +7521,7 @@ components_to_record (Node_Id gnat_component_list, Entity_Id gnat_record_type,
bool all_rep_and_size = all_rep && TYPE_SIZE (gnu_record_type);
bool variants_have_rep = all_rep;
bool layout_with_rep = false;
+ bool has_non_packed_fixed_size_field = false;
bool has_self_field = false;
bool has_aliased_after_self_field = false;
Entity_Id gnat_component_decl, gnat_variant_part;
@@ -7577,6 +7578,10 @@ components_to_record (Node_Id gnat_component_list, Entity_Id gnat_record_type,
has_self_field = true;
else if (has_self_field && DECL_ALIASED_P (gnu_field))
has_aliased_after_self_field = true;
+ else if (!DECL_FIELD_OFFSET (gnu_field)
+ && !DECL_PACKED (gnu_field)
+ && !field_has_variable_size (gnu_field))
+ has_non_packed_fixed_size_field = true;
}
}
@@ -7868,8 +7873,9 @@ components_to_record (Node_Id gnat_component_list, Entity_Id gnat_record_type,
self-referential/variable offset or misaligned. Note, in the latter
case, that this can only happen in packed record types so the alignment
is effectively capped to the byte for the whole record. But we don't
- do it for non-packed record types if pragma Optimize_Alignment (Space)
- is specified because this can prevent alignment gaps from being filled.
+ do it for packed record types if not all fixed-size fiels can be packed
+ and for non-packed record types if pragma Optimize_Alignment (Space) is
+ specified, because this can prevent alignment gaps from being filled.
Optionally, if the layout warning is enabled, keep track of the above 4
different kinds of fields and issue a warning if some of them would be
@@ -7880,8 +7886,9 @@ components_to_record (Node_Id gnat_component_list, Entity_Id gnat_record_type,
const bool do_reorder
= (Convention (gnat_record_type) == Convention_Ada
&& !No_Reordering (gnat_record_type)
- && (!Optimize_Alignment_Space (gnat_record_type)
- || Is_Packed (gnat_record_type))
+ && !(Is_Packed (gnat_record_type)
+ ? has_non_packed_fixed_size_field
+ : Optimize_Alignment_Space (gnat_record_type))
&& !debug__debug_flag_dot_r);
const bool w_reorder
= (Convention (gnat_record_type) == Convention_Ada