aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada
diff options
context:
space:
mode:
authorOlivier Hainque <hainque@adacore.com>2007-09-12 10:49:56 +0000
committerOlivier Hainque <hainque@gcc.gnu.org>2007-09-12 10:49:56 +0000
commit09528ed9bf63847d9b49758a315737ace1d260f7 (patch)
tree5543744f197541b0fb5030e363961717337de155 /gcc/ada
parent7ab886543206b714b7e90e447446c0128d7638cb (diff)
downloadgcc-09528ed9bf63847d9b49758a315737ace1d260f7.zip
gcc-09528ed9bf63847d9b49758a315737ace1d260f7.tar.gz
gcc-09528ed9bf63847d9b49758a315737ace1d260f7.tar.bz2
decl.c (gnat_to_gnu_entity): For a subtype with discriminant constraints...
2007-09-12 Olivier Hainque <hainque@adacore.com> ada/ * decl.c (gnat_to_gnu_entity) <E_Record_Subtype>: For a subtype with discriminant constraints, generalize the code for BIT_FIELDs to PACKED fields of constant size and propagate DECL_PACKED. testsuite/ * gnat.dg/packed_subtype.adb: New test. From-SVN: r128425
Diffstat (limited to 'gcc/ada')
-rw-r--r--gcc/ada/ChangeLog6
-rw-r--r--gcc/ada/decl.c13
2 files changed, 15 insertions, 4 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog
index 6951351..fca0cd0 100644
--- a/gcc/ada/ChangeLog
+++ b/gcc/ada/ChangeLog
@@ -1,3 +1,9 @@
+2007-09-12 Olivier Hainque <hainque@adacore.com>
+
+ * decl.c (gnat_to_gnu_entity) <E_Record_Subtype>: For a subtype
+ with discriminant constraints, generalize the code for BIT_FIELDs
+ to PACKED fields of constant size and propagate DECL_PACKED.
+
2007-09-11 Eric Botcazou <ebotcazou@adacore.com>
* decl.c (array_type_has_nonaliased_component): New predicate.
diff --git a/gcc/ada/decl.c b/gcc/ada/decl.c
index 3d7c849..4b3edce 100644
--- a/gcc/ada/decl.c
+++ b/gcc/ada/decl.c
@@ -2762,9 +2762,14 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
gnu_field_type = TREE_TYPE (gnu_old_field);
}
- /* If this was a bitfield, get the size from the old field.
- Also ensure the type can be placed into a bitfield. */
- else if (DECL_BIT_FIELD (gnu_old_field))
+ /* If the old field was packed and of constant size, we
+ have to get the old size here, as it might differ from
+ what the Etype conveys and the latter might overlap
+ onto the following field. Try to arrange the type for
+ possible better packing along the way. */
+ else if (DECL_PACKED (gnu_old_field)
+ && TREE_CODE (DECL_SIZE (gnu_old_field))
+ == INTEGER_CST)
{
gnu_size = DECL_SIZE (gnu_old_field);
if (TYPE_MODE (gnu_field_type) == BLKmode
@@ -2789,7 +2794,7 @@ gnat_to_gnu_entity (Entity_Id gnat_entity, tree gnu_expr, int definition)
gnu_field
= create_field_decl
(DECL_NAME (gnu_old_field), gnu_field_type, gnu_type,
- 0, gnu_size, gnu_new_pos,
+ DECL_PACKED (gnu_old_field), gnu_size, gnu_new_pos,
!DECL_NONADDRESSABLE_P (gnu_old_field));
if (!TREE_CONSTANT (gnu_pos))