From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x135.google.com (mail-lf1-x135.google.com [IPv6:2a00:1450:4864:20::135]) by sourceware.org (Postfix) with ESMTPS id 18E233858C50 for ; Mon, 22 May 2023 12:15:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 18E233858C50 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-x135.google.com with SMTP id 2adb3069b0e04-4f004cc54f4so7028578e87.3 for ; Mon, 22 May 2023 05:15:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684757753; x=1687349753; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=NT3GSZqPNI8w93SgQgAI7JPtLn9GsdGNhyT0lgNYIxU=; b=UlW6Yk2ZRyM6T+nuvYHoMwAXqtxUWUDeQ7JQXJuVo5LSnGcygOgCXegT7Po4LTkowK Esj6JB4mr2upMVSVe/A7veqW7dzORoxFOCldevBIDQrfWi3N0zBjoD7PRObDnRaJA+K3 X1iVRlCVb6MTlqqxS3ZU1Cq5HSn6aCJFE/loPz3GA/sglpcXM5rj+JhlC1/QJCtITHKB MyPRof4+x/Vwlb0X8kXn+9GXdqOnC3ha4xbgB1D+Bcdl5J3JoyzS2MnrD8AN2+5ZzU5H 4MQU0sD0dGV+H64E3qKZrPVvVCbh0zaFW3bPyyqj9cx12C2HRov4+sLBMqDo3zQvLsi8 WF6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684757753; x=1687349753; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NT3GSZqPNI8w93SgQgAI7JPtLn9GsdGNhyT0lgNYIxU=; b=GK9sK64sXyf6QE1dM0pVLfK1eyJ2SjuRto5u2nySdVODXUCuhAcgEOew9M+Dq6SwmR pwES49rEpKuVE2Z681rhpPhgIvoYQePwbixsaGW9ABULxoPtahp/VP9IQM6w8/evn7Xp ukHxvbr3e3J4KFi6yi/5GPcnTbuOTipjKEKoxGJ4Ta3tQXVwyz96qGF9iHx0pl+H/g0V DH8B51lvLh3PDdT2XWeMsudxhzkeYB0xn/EJlPxgXdhdb06uZ6pZDFfEDRNgRsF4kMh2 crPR5cHSud9rOUnPTFh98Gt9KQD8PBWp3+StBbmG0pjeb1sDNyEydVQnW+JGqRNqLS/H 1u5g== X-Gm-Message-State: AC+VfDxB02rW/CKfu3XiuoB2yYaoRe8jmXDtS1/40GT7Vw1seUjBjf2C w15ihoLAFmWPzsioE0LW+dRiuKxA9kRDe0hdAqk= X-Google-Smtp-Source: ACHHUZ7mtLGMAgABxvj0goYcFIuwoBwQchBVdyDUYbaKuL8Jd2Bj4sx3yEdrLSzSdQkgVGRz6Inji3SiAnhbjruAzYU= X-Received: by 2002:ac2:4c18:0:b0:4f3:9868:bee4 with SMTP id t24-20020ac24c18000000b004f39868bee4mr3853977lfq.32.1684757753192; Mon, 22 May 2023 05:15:53 -0700 (PDT) MIME-Version: 1.0 References: <13270277.uLZWGnKmhe@fomalhaut> In-Reply-To: <13270277.uLZWGnKmhe@fomalhaut> From: Richard Biener Date: Mon, 22 May 2023 14:15:40 +0200 Message-ID: Subject: Re: [PATCH] Fix handling of non-integral bit-fields in native_encode_initializer To: Eric Botcazou Cc: gcc-patches@gcc.gnu.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, May 22, 2023 at 10:10=E2=80=AFAM Eric Botcazou via Gcc-patches 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 star= t 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 pla= ce? Or is that not worth it? Thanks, Richard. > > > 2023-05-22 Eric Botcazou > > * fold-const.cc (native_encode_initializer) : Apply = the > specific treatment for bit-fields only if they have an integral t= ype > and filter out non-integral bit-fields that do not start and end = on > a byte boundary. > > > 2023-05-22 Eric Botcazou > > * gnat.dg/opt101.adb: New test. > * gnat.dg/opt101_pkg.ads: New helper. > > -- > Eric Botcazou