diff options
author | Olivier Hainque <hainque@adacore.com> | 2007-12-07 10:50:23 +0000 |
---|---|---|
committer | Olivier Hainque <hainque@gcc.gnu.org> | 2007-12-07 10:50:23 +0000 |
commit | 5a2fe31acfc1f03b8954b1d5358ce8411772423e (patch) | |
tree | 4a1f91a442cfdd5c6bb0f36d7cf1872f25eda846 /gcc/ada/utils.c | |
parent | 9225443e8ba248edba04c757fb624d9be372e049 (diff) | |
download | gcc-5a2fe31acfc1f03b8954b1d5358ce8411772423e.zip gcc-5a2fe31acfc1f03b8954b1d5358ce8411772423e.tar.gz gcc-5a2fe31acfc1f03b8954b1d5358ce8411772423e.tar.bz2 |
re PR ada/34173 (FAIL: gnat.dg/release_unc_maxalign.adb execution test)
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.
From-SVN: r130673
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 33448fc..9e90ba1 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) { |