aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2017-02-24 11:03:08 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2017-02-24 11:03:08 +0000
commit741bd9b135cf2f8e123a41dea93d8bb20c3e0ae9 (patch)
treef47f21e750a47b6012707167a1c79015a0b1111d /gcc
parent70e1d145c876a7880a03cd1f1777c0d73f0ba1f1 (diff)
downloadgcc-741bd9b135cf2f8e123a41dea93d8bb20c3e0ae9.zip
gcc-741bd9b135cf2f8e123a41dea93d8bb20c3e0ae9.tar.gz
gcc-741bd9b135cf2f8e123a41dea93d8bb20c3e0ae9.tar.bz2
decl.c (gnat_to_gnu_field): Do not remove the wrapper around a justified modular type if...
* gcc-interface/decl.c (gnat_to_gnu_field): Do not remove the wrapper around a justified modular type if it doesn't have the same scalar storage order as the enclosing record type. From-SVN: r245710
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/gcc-interface/decl.c13
2 files changed, 14 insertions, 5 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index addb1cb..e4ce4d5 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,5 +1,11 @@
2017-02-24 Eric Botcazou <ebotcazou@adacore.com>
+ * gcc-interface/decl.c (gnat_to_gnu_field): Do not remove the wrapper
+ around a justified modular type if it doesn't have the same scalar
+ storage order as the enclosing record type.
+
+2017-02-24 Eric Botcazou <ebotcazou@adacore.com>
+
* gcc-interface/trans.c (gnat_to_gnu): Do not apply special handling
of boolean rvalues to function calls.
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index b493e80..35fd92f 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -7031,6 +7031,7 @@ static tree
gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
bool definition, bool debug_info_p)
{
+ const Entity_Id gnat_record_type = Underlying_Type (Scope (gnat_field));
const Entity_Id gnat_field_type = Etype (gnat_field);
const bool is_aliased
= Is_Aliased (gnat_field);
@@ -7117,8 +7118,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
if (Present (Component_Clause (gnat_field)))
{
Node_Id gnat_clause = Component_Clause (gnat_field);
- Entity_Id gnat_parent
- = Parent_Subtype (Underlying_Type (Scope (gnat_field)));
+ Entity_Id gnat_parent = Parent_Subtype (gnat_record_type);
gnu_pos = UI_To_gnu (Component_Bit_Offset (gnat_field), bitsizetype);
gnu_size = validate_size (Esize (gnat_field), gnu_field_type,
@@ -7237,7 +7237,7 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
/* If the record has rep clauses and this is the tag field, make a rep
clause for it as well. */
- else if (Has_Specified_Layout (Scope (gnat_field))
+ else if (Has_Specified_Layout (gnat_record_type)
&& Chars (gnat_field) == Name_uTag)
{
gnu_pos = bitsize_zero_node;
@@ -7274,11 +7274,14 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
/* If the field's type is justified modular, we would need to remove
the wrapper to (better) meet the layout requirements. However we
can do so only if the field is not aliased to preserve the unique
- layout and if the prescribed size is not greater than that of the
- packed array to preserve the justification. */
+ layout, if it has the same storage order as the enclosing record
+ and if the prescribed size is not greater than that of the packed
+ array to preserve the justification. */
if (!needs_strict_alignment
&& TREE_CODE (gnu_field_type) == RECORD_TYPE
&& TYPE_JUSTIFIED_MODULAR_P (gnu_field_type)
+ && TYPE_REVERSE_STORAGE_ORDER (gnu_field_type)
+ == Reverse_Storage_Order (gnat_record_type)
&& tree_int_cst_compare (gnu_size, TYPE_ADA_SIZE (gnu_field_type))
<= 0)
gnu_field_type = TREE_TYPE (TYPE_FIELDS (gnu_field_type));