On Mon, May 22, 2023 at 10:10 AM Eric Botcazou via Gcc-patches
<gcc-patches@gcc.gnu.org> wrote:
>
> Hi,
>
> the encoder for CONSTRUCTORs assumes that all bit-fields (DECL_BIT_FIELD) have
> integral types, but that's not the case in Ada where they may have pretty much
> any type, resulting in a wrong encoding for them.
>
> The attached fix filters out non-integral bit-fields, except if they start and
> end on a byte boundary because they are correctly handled in this case.
>
> Bootstrapped/regtested on x86-64/Linux, OK for mainline and 13 branch?

OK.

Can we handle non-integer bitfields by recursing with a temporary buffer to
encode it byte-aligned and then apply shifting and masking to get it in place?
Or is that not worth it?

Thanks,
Richard.

>
>
> 2023-05-22  Eric Botcazou  <ebotca...@adacore.com>
>
>         * fold-const.cc (native_encode_initializer) <CONSTRUCTOR>: Apply the
>         specific treatment for bit-fields only if they have an integral type
>         and filter out non-integral bit-fields that do not start and end on
>         a byte boundary.
>
>
> 2023-05-22  Eric Botcazou  <ebotca...@adacore.com>
>
>         * gnat.dg/opt101.adb: New test.
>         * gnat.dg/opt101_pkg.ads: New helper.
>
> --
> Eric Botcazou

Reply via email to