diff options
author | hainque <hainque@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-12-07 10:50:23 +0000 |
---|---|---|
committer | hainque <hainque@138bc75d-0d04-0410-961f-82ee72b054a4> | 2007-12-07 10:50:23 +0000 |
commit | 72f6e27c1511d828a4dec7a91488499c149d213c (patch) | |
tree | 4a1f91a442cfdd5c6bb0f36d7cf1872f25eda846 /gcc/ada/utils.c | |
parent | f81207a71959aba2d49077f6925e5a29f72f6dd7 (diff) | |
download | gcc-72f6e27c1511d828a4dec7a91488499c149d213c.tar.gz |
2007-12-07 Olivier Hainque <hainque@adacore.com>
PR ada/34173
* decl.c (gnat_to_gnu_entity) <case E_Array_Type>: When setting
the alignment on the GCC XUA array type, set TYPE_USER_ALIGN if
this is from an alignment clause on the GNAT entity.
* utils.c (create_field_decl): Rewrite the computation of DECL_ALIGN
to distinguish the case where we set it from the type's alignment.
When so, propagate TYPE_USER_ALIGN into DECL_USER_ALIGN to indicate
whether this alignment was set from an explicit alignment clause.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130673 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/utils.c')
-rw-r--r-- | gcc/ada/utils.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/gcc/ada/utils.c b/gcc/ada/utils.c index 33448fc9363..9e90ba1fbe3 100644 --- a/gcc/ada/utils.c +++ b/gcc/ada/utils.c @@ -1581,11 +1581,24 @@ create_field_decl (tree field_name, tree field_type, tree record_type, } DECL_PACKED (field_decl) = pos ? DECL_BIT_FIELD (field_decl) : packed; - DECL_ALIGN (field_decl) - = MAX (DECL_ALIGN (field_decl), - DECL_BIT_FIELD (field_decl) ? 1 - : packed && TYPE_MODE (field_type) != BLKmode ? BITS_PER_UNIT - : TYPE_ALIGN (field_type)); + + /* Bump the alignment if need be, either for bitfield/packing purposes or + to satisfy the type requirements if no such consideration applies. When + we get the alignment from the type, indicate if this is from an explicit + user request, which prevents stor-layout from lowering it later on. */ + { + int bit_align + = (DECL_BIT_FIELD (field_decl) ? 1 + : packed && TYPE_MODE (field_type) != BLKmode ? BITS_PER_UNIT : 0); + + if (bit_align > DECL_ALIGN (field_decl)) + DECL_ALIGN (field_decl) = bit_align; + else if (!bit_align && TYPE_ALIGN (field_type) > DECL_ALIGN (field_decl)) + { + DECL_ALIGN (field_decl) = TYPE_ALIGN (field_type); + DECL_USER_ALIGN (field_decl) = TYPE_USER_ALIGN (field_type); + } + } if (pos) { |