aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2009-05-20 08:29:05 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2009-05-20 08:29:05 +0000
commit3f6f0eb2e4a89be2eed80ad57bf003c3fc0aa210 (patch)
treea1d15575a02c86f92afa7b0142475e7ae7b5ce3c /gcc
parent0328ae4d560fdd0e50c48c65660c489e36ab8ca5 (diff)
downloadgcc-3f6f0eb2e4a89be2eed80ad57bf003c3fc0aa210.zip
gcc-3f6f0eb2e4a89be2eed80ad57bf003c3fc0aa210.tar.gz
gcc-3f6f0eb2e4a89be2eed80ad57bf003c3fc0aa210.tar.bz2
decl.c (gnat_to_gnu_entity): When discriminants affect the shape of the subtype...
* gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Subtype>: When discriminants affect the shape of the subtype, retrieve the GCC type directly from the original field if the GNAT types for the field and the original field are the same. From-SVN: r147732
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/ChangeLog7
-rw-r--r--gcc/ada/gcc-interface/decl.c30
2 files changed, 26 insertions, 11 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 0548b21..d7396f1 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,10 @@
+2009-05-20 Eric Botcazou <ebotcazou@adacore.com>
+
+ * gcc-interface/decl.c (gnat_to_gnu_entity) <E_Record_Subtype>: When
+ discriminants affect the shape of the subtype, retrieve the GCC type
+ directly from the original field if the GNAT types for the field and
+ the original field are the same.
+
2009-05-15 Eric Botcazou <ebotcazou@adacore.com>
* gcc-interface/ada-tree.h (TYPE_GCC_MIN_VALUE, TYPE_GCC_MAX_VALUE):
diff --git a/gcc/ada/gcc-interface/decl.c b/gcc/ada/gcc-interface/decl.c
index 46215da..649b9ef 100644
--- a/gcc/ada/gcc-interface/decl.c
+++ b/gcc/ada/gcc-interface/decl.c
@@ -3124,21 +3124,27 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
|| !Is_Tagged_Type (gnat_base_type)))
{
tree gnu_old_field
- = gnat_to_gnu_field_decl (Original_Record_Component
- (gnat_field));
+ = gnat_to_gnu_field_decl
+ (Original_Record_Component (gnat_field));
tree gnu_offset
- = TREE_VALUE (purpose_member (gnu_old_field,
- gnu_pos_list));
+ = TREE_VALUE
+ (purpose_member (gnu_old_field, gnu_pos_list));
tree gnu_pos = TREE_PURPOSE (gnu_offset);
tree gnu_bitpos = TREE_VALUE (TREE_VALUE (gnu_offset));
- tree gnu_field_type
- = gnat_to_gnu_type (Etype (gnat_field));
- tree gnu_size = TYPE_SIZE (gnu_field_type);
- tree gnu_new_pos = NULL_TREE;
+ tree gnu_field, gnu_field_type, gnu_size, gnu_new_pos;
unsigned int offset_align
- = tree_low_cst (TREE_PURPOSE (TREE_VALUE (gnu_offset)),
- 1);
- tree gnu_field;
+ = tree_low_cst
+ (TREE_PURPOSE (TREE_VALUE (gnu_offset)), 1);
+
+ /* If the type is the same, retrieve the GCC type from the
+ old field to take into account possible adjustments. */
+ if (Etype (gnat_field)
+ == Etype (Original_Record_Component (gnat_field)))
+ gnu_field_type = TREE_TYPE (gnu_old_field);
+ else
+ gnu_field_type = gnat_to_gnu_type (Etype (gnat_field));
+
+ gnu_size = TYPE_SIZE (gnu_field_type);
/* If there was a component clause, the field types must be
the same for the type and subtype, so copy the data from
@@ -3197,6 +3203,8 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
TYPE_SIZE (gnu_type)))
continue;
}
+ else
+ gnu_new_pos = NULL_TREE;
gnu_field
= create_field_decl