From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x12b.google.com (mail-lf1-x12b.google.com [IPv6:2a00:1450:4864:20::12b]) by sourceware.org (Postfix) with ESMTPS id 629F03858D28 for ; Mon, 3 Jul 2023 13:27:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 629F03858D28 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4fb94b1423eso6680643e87.1 for ; Mon, 03 Jul 2023 06:27:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1688390832; x=1690982832; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=eWK1w1HCJayKtAAk+GvDgOLn3drO6Y/zWrQ2wYvRgMM=; b=Ngtq/rGbpuDinbttqdtQ0XFROXaZYNZWNMqhUG1KJM+jRmj/DZ3sXvXFocsvcZTf2P bgmrvY9XhhrfP616q9yxHgYxC4i+WJ8xZkskIDVixo4EBJU07V08wS7TiHME9fluejjM Ha32ao2nbhMV1CW/pzu+mFK/8nRa/uFUTx5XIOqHyA/TREdqTxJmrlPtP6twaeBSGI/U wtAOJDWchAy082LaNcaev8rjSiulLUaPkFzLe96AvB3RmUetkCss16RGXSmuc15uaN9Y s8mFRQs+lRXeBGixRItsNX/Ew1XaimPFqKov151HOukkTTrm4sZ26/YP8vvDQrLGilOZ avwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688390832; x=1690982832; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=eWK1w1HCJayKtAAk+GvDgOLn3drO6Y/zWrQ2wYvRgMM=; b=mACBsLiN4azeXVnuczUJvnERrovKNezsL+OwbiFU4iIy6BNiIjDjHVVAyiY2B9BzIN YSCAntk0cItPK10bUNGtIF6jdXo91WLxSLWeWKw79dWQAgRJX7YbXzPQAH702g6bQvwb WJrnNQB1mIiziEPcz/mVtbi1AALyoX53sAeRKR1dE6kdod6qvfiaUAiYWgYehg+hgOui FPp2wa7EMFfOlqgjuSdy9MaLGhvo6GX6QV/z/L0bV+Llpxv/s43ZN+Mucw81F/rNdv7v 7iikKCUvnO9/km8qyQzJIJBJ023XT0WxIYfyCe4kRDMLQ5EsqiKhkcGaJfYDDI6O5hrj nXEg== X-Gm-Message-State: ABy/qLa2eMZUfgpqqwOyUwNaNlRj0dt95Itth/0YO0vtit4l1+vPhQYl qRk6n+3o/1z02Cob5ku3QZcNCMLqbv874aQOIpnIPQ== X-Google-Smtp-Source: APBJJlFAyyy2c4QzekJY8QRlWGMwSSSiXL0PBlxEruPdG2O38BLUHhqrH41xjHXaFyc8kyy8VG6P1Q== X-Received: by 2002:a19:9146:0:b0:4fb:7559:aea3 with SMTP id y6-20020a199146000000b004fb7559aea3mr5545515lfj.39.1688390831829; Mon, 03 Jul 2023 06:27:11 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:b3e5:da4f:72d8:3c]) by smtp.gmail.com with ESMTPSA id p8-20020a7bcc88000000b003fb225d414fsm20596843wma.21.2023.07.03.06.27.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jul 2023 06:27:11 -0700 (PDT) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: Eric Botcazou Subject: [COMMITTED] ada: Fix small inaccuracy in implementation of B.3.3(20/2) Date: Mon, 3 Jul 2023 15:27:00 +0200 Message-Id: <20230703132700.880979-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,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: From: Eric Botcazou This is the clause about inferable discriminants in unchecked unions. gcc/ada/ * sem_util.adb (Has_Inferable_Discriminants): In the case of a component with a per-object constraint, also return true if the enclosing object is not of an unchecked union type. In the default case, remove a useless call to Base_Type. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index d9ea00e53cb..736751f5fae 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -12272,33 +12272,26 @@ package body Sem_Util is begin -- For selected components, the subtype of the selector must be a -- constrained Unchecked_Union. If the component is subject to a - -- per-object constraint, then the enclosing object must have inferable - -- discriminants. + -- per-object constraint, then the enclosing object must either be + -- a regular discriminated type or must have inferable discriminants. if Nkind (N) = N_Selected_Component then - if Has_Per_Object_Constraint (Entity (Selector_Name (N))) then - - -- A small hack. If we have a per-object constrained selected - -- component of a formal parameter, return True since we do not - -- know the actual parameter association yet. - - if Prefix_Is_Formal_Parameter (N) then - return True; - - -- Otherwise, check the enclosing object and the selector - - else - return Has_Inferable_Discriminants (Prefix (N)) - and then Has_Inferable_Discriminants (Selector_Name (N)); - end if; - -- The call to Has_Inferable_Discriminants will determine whether -- the selector has a constrained Unchecked_Union nominal type. - else - return Has_Inferable_Discriminants (Selector_Name (N)); + if not Has_Inferable_Discriminants (Selector_Name (N)) then + return False; end if; + -- A small hack. If we have a per-object constrained selected + -- component of a formal parameter, return True since we do not + -- know the actual parameter association yet. + + return not Has_Per_Object_Constraint (Entity (Selector_Name (N))) + or else not Is_Unchecked_Union (Etype (Prefix (N))) + or else Has_Inferable_Discriminants (Prefix (N)) + or else Prefix_Is_Formal_Parameter (N); + -- A qualified expression has inferable discriminants if its subtype -- mark is a constrained Unchecked_Union subtype. @@ -12310,7 +12303,7 @@ package body Sem_Util is -- Unchecked_Union nominal subtype. else - return Is_Unchecked_Union (Base_Type (Etype (N))) + return Is_Unchecked_Union (Etype (N)) and then Is_Constrained (Etype (N)); end if; end Has_Inferable_Discriminants; -- 2.40.0