]> git.ipfire.org Git - thirdparty/gcc.git/commit
ada: Allow implicit packing of arrays when larger than needed
authorBob Duff <duff@adacore.com>
Sun, 17 Aug 2025 15:23:23 +0000 (11:23 -0400)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 11 Sep 2025 09:10:47 +0000 (11:10 +0200)
commite39c326733d0cd20403ac1ccc578d9c63f3d0aa8
tree377d83b71c72ae361a63667871c13346c71f01c1
parentf2ba38d3babe484b65726cea9f750a57f4951228
ada: Allow implicit packing of arrays when larger than needed

For Implicit_Packing, do not require the Size clause to exactly match
the packed size.

For example, an array of 7 Booleans will fit in
7 bits if packed, or 7*8=56 bits if not packed.
This patch allows "for T'Size use 8;" to force packing
in Implicit_Packing mode; previously, the compiler
ignored Implicit_Packing unless it was exactly "use 7".

Apparently, customers have that sort of code, and the
whole point of Implicit_Packing is to allow such legacy
code to work.

We already do the right thing for records, at least in
cases tested.

We deliberately avoid changing the error messages given here.
They could possibly use some work, but there are subtle interactions
with the messages given in Sem_Ch13 for the same thing.

gcc/ada/ChangeLog:

* freeze.adb (Freeze_Entity): Change "=" to ">=" in
size comparison for Implicit_Packing mode.
Keep it as "=" for giving error messages.
* opt.ads (Implicit_Packing): Minor: correct obsolete
comment.
gcc/ada/freeze.adb
gcc/ada/opt.ads