aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-09-28 16:25:31 +0200
committerMarc Poulhiès <poulhies@adacore.com>2023-10-10 14:12:29 +0200
commit2f150833b4edaad314f61a91d46b7f871661df15 (patch)
treeff33eade5e6e8d2f22e358b0c829e85c9e9b9bbc /gcc
parent42c46cfe8c6d626c7a8b2530e0da6e150a6f9a2a (diff)
downloadgcc-2f150833b4edaad314f61a91d46b7f871661df15.zip
gcc-2f150833b4edaad314f61a91d46b7f871661df15.tar.gz
gcc-2f150833b4edaad314f61a91d46b7f871661df15.tar.bz2
ada: Fix internal error on too large representation clause for small component
This is a small bug present on strict-alignment platforms for questionable representation clauses. gcc/ada/ * gcc-interface/decl.cc (inline_status_for_subprog): Minor tweak. (gnat_to_gnu_field): Try harder to get a packable form of the type for a bitfield.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/gcc-interface/decl.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/gcc/ada/gcc-interface/decl.cc b/gcc/ada/gcc-interface/decl.cc
index 5e16b56..20ab185 100644
--- a/gcc/ada/gcc-interface/decl.cc
+++ b/gcc/ada/gcc-interface/decl.cc
@@ -5114,7 +5114,7 @@ inline_status_for_subprog (Entity_Id subprog)
tree gnu_type;
/* This is a kludge to work around a pass ordering issue: for small
- record types with many components, i.e. typically bit-fields, the
+ record types with many components, i.e. typically bitfields, the
initialization routine can contain many assignments that will be
merged by the GIMPLE store merging pass. But this pass runs very
late in the pipeline, in particular after the inlining decisions
@@ -7702,6 +7702,18 @@ gnat_to_gnu_field (Entity_Id gnat_field, tree gnu_record_type, int packed,
gnu_field_type = maybe_pad_type (gnu_field_type, gnu_size, 0, gnat_field,
false, definition, true);
+ /* For a bitfield, if the type still has BLKmode, try again to change it
+ to an integral mode form. This may be necessary on strict-alignment
+ platforms with a size clause that is much larger than the field type,
+ because maybe_pad_type has preserved the alignment of the field type,
+ which may be too low for the new size. */
+ if (!needs_strict_alignment
+ && RECORD_OR_UNION_TYPE_P (gnu_field_type)
+ && !TYPE_FAT_POINTER_P (gnu_field_type)
+ && TYPE_MODE (gnu_field_type) == BLKmode
+ && is_bitfield)
+ gnu_field_type = make_packable_type (gnu_field_type, true, 1);
+
/* If a padding record was made, declare it now since it will never be
declared otherwise. This is necessary to ensure that its subtrees
are properly marked. */