From 04bc3c93bec894ca85bc448b40af42545a280928 Mon Sep 17 00:00:00 2001 From: Eric Botcazou Date: Mon, 15 May 2017 08:00:41 +0000 Subject: [PATCH] decl.c (gnat_to_gnu_entity): When there is a representation clause on an extension... * gcc-interface/decl.c (gnat_to_gnu_entity) : When there is a representation clause on an extension, propagate the alignment of the parent type only if the platform requires strict alignment. From-SVN: r248049 --- gcc/ada/ChangeLog | 6 ++++++ gcc/ada/gcc-interface/decl.c | 16 ++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 0dd6d04bc7c..dc2916e5278 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,9 @@ +2017-05-15 Eric Botcazou + + * gcc-interface/decl.c (gnat_to_gnu_entity) : When there + is a representation clause on an extension, propagate the alignment of + the parent type only if the platform requires strict alignment. + 2017-05-12 Eric Botcazou * system-linux-arm.ads (Memory_Size): Use Long_Integer'Size diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c index af4574d2c62..b39b75a852b 100644 --- a/gcc/ada/gcc-interface/decl.c +++ b/gcc/ada/gcc-interface/decl.c @@ -204,6 +204,7 @@ static tree elaborate_expression_2 (tree, Entity_Id, const char *, bool, bool, static tree elaborate_reference (tree, Entity_Id, bool, tree *); static tree gnat_to_gnu_component_type (Entity_Id, bool, bool); static tree gnat_to_gnu_subprog_type (Entity_Id, bool, bool, tree *); +static int adjust_packed (tree, tree, int); static tree gnat_to_gnu_field (Entity_Id, tree, int, bool, bool); static tree gnu_ext_name_for_subprog (Entity_Id, tree); static tree change_qualified_type (tree, int); @@ -3094,6 +3095,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) Entity_Id gnat_parent = Parent_Subtype (gnat_entity); tree gnu_dummy_parent_type = make_node (RECORD_TYPE); tree gnu_parent; + int parent_packed = 0; /* A major complexity here is that the parent subtype will reference our discriminants in its Stored_Constraint list. @@ -3172,7 +3174,17 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) be created with a component clause below, then we need to apply the same adjustment as in gnat_to_gnu_field. */ if (has_rep && TYPE_ALIGN (gnu_type) < TYPE_ALIGN (gnu_parent)) - SET_TYPE_ALIGN (gnu_type, TYPE_ALIGN (gnu_parent)); + { + /* ??? For historical reasons, we do it on strict-alignment + platforms only, where it is really required. This means + that a confirming representation clause will change the + behavior of the compiler on the other platforms. */ + if (STRICT_ALIGNMENT) + SET_TYPE_ALIGN (gnu_type, TYPE_ALIGN (gnu_parent)); + else + parent_packed + = adjust_packed (gnu_parent, gnu_type, parent_packed); + } /* Finally we fix up both kinds of twisted COMPONENT_REF we have initially built. The discriminants must reference the fields @@ -3218,7 +3230,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, bool definition) ? TYPE_SIZE (gnu_parent) : NULL_TREE, has_rep ? bitsize_zero_node : NULL_TREE, - 0, 1); + parent_packed, 1); DECL_INTERNAL_P (gnu_field) = 1; TREE_OPERAND (gnu_get_parent, 1) = gnu_field; TYPE_FIELDS (gnu_type) = gnu_field; -- 2.30.2