From patchwork Fri Jul 28 07:30:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Marc_Poulhi=C3=A8s?= X-Patchwork-Id: 127376 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp259012vqg; Fri, 28 Jul 2023 00:33:20 -0700 (PDT) X-Google-Smtp-Source: APBJJlGE6LrJSVzqTXkSENvzLYBmghHeXCPOcx9I8B4AaUhQNY2Fbq2bvTSXg0ZZ2fYcXJKbB4vx X-Received: by 2002:aa7:d145:0:b0:522:203d:c9b1 with SMTP id r5-20020aa7d145000000b00522203dc9b1mr1191998edo.11.1690529600191; Fri, 28 Jul 2023 00:33:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690529600; cv=none; d=google.com; s=arc-20160816; b=XEeuQi3hYfqOkU59ZJ/2V9lKvc4BaxybRDNVLPiy14mg/icAi415OdN/QDgtYZzQqA As2rdnzor2Ij3K3UeSn5e8ZVZrn/KhtZtXzQCisG5EpyarUm9cFi9TWt3KHJU2HpoNEX 1KNSkkMKrzYUSvyfV9Yrvk0uFFgr3hFI77uFh8DFlnBHrC3uXOy5W27pgdJn1VNEYizv 4M13cQ91rFXFyw7JiURrPCHj037E/J8v7R+lDjD53+eSAKmiJOm2Gx/Sy6coqMLxeiVU RDrzirPVdCvq2Y423maLgULj+fDJ0wF/hwMCkQJ3aK8Ayl7CWxCYWRFloqdV9kpxmeFM uNZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:cc :to:dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=t/UsrShTuuKbEUdKCltKkTOmNecto7gB9e9J0JAYWOY=; fh=Lj1VijP3LnkAVEPcMi7kRiXijG3l76C04Ep5oiVm8fk=; b=NrYeDX2gEt5kHa2PABAiVbv2lxFDN+SEGQZFZ3gowqxn4iTTg1oGUXJYNQoF/77udx Or2RIXQy/PYJZx4pCAON+3rBtKKDwkQvkSuvS+pjs4ji73L9Ng/ieBTdwelypBA5Opmh SL4blHkxo6krqqfEn3HvgCzmxps99yzMf3wFpKfG8pnJ/B0FPDgcdCN2/4CBc1heefmN wYUJN4+hbPkn1kyQ73FuG0nVqsqFviMMLAvcZPERjHle0Czb2Di13eWkw/Phjq8xGRdI UZqfaYsiJFqhxXHUnwbbqJt2jOD7GeplLb4szDfZdWOGIBEYXigrkMqudjJYbBkr9LkK nROA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xRKgBKIj; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id y18-20020aa7c252000000b00522582cf40dsi2127709edo.244.2023.07.28.00.33.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 00:33:20 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=xRKgBKIj; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B7DC13842314 for ; Fri, 28 Jul 2023 07:31:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B7DC13842314 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1690529500; bh=t/UsrShTuuKbEUdKCltKkTOmNecto7gB9e9J0JAYWOY=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=xRKgBKIjKEd2kBTIExgawr4iay1Rt3gctYjm+f9yYYbXBx9uQ+YRX0Eos5Xv11Swp M4rs4cTZFm/1VlEGOpxjdlJzeN862w3xxvGLI8iKYw+ZAGIwtbEerNAfJq07m4JOIU Au6+kth5wPcCfDwC/tQJK7vLZ/B6QefESmvstfBI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 CC31D3856973 for ; Fri, 28 Jul 2023 07:30:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CC31D3856973 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-4f95bf5c493so3075740e87.3 for ; Fri, 28 Jul 2023 00:30:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690529444; x=1691134244; 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=t/UsrShTuuKbEUdKCltKkTOmNecto7gB9e9J0JAYWOY=; b=L/ur/x/qDevO3NK+XVe07TwNSA/CKPTZucaoD/OoqgRWBqY47P76iyJGO/qI3eh5LH 6dPjZXDgaZ3X1bLDYqmOnxAuxSqwF4aHmOEYSohKtXYIZE2Qp9a8gqvbcIvU9w9Zw7e2 FpRsTHvVm4njo0sThqrVWj8HO7Doan+9RgGsGKvs1+Os/MkqA7BlZYeQFvsuyRj8TyvP yOl/q7w+UEdhdk5vaiOCkZOTYU6WulEptytAxJ7SI4PSEGnIF5MLLGZvwKCkHTXZfANS qCUIgxbBKBwO99cGNyMggO5rBXB3JtOe3KCAmkP6hUr8fUSp1nEa+zzmt3MfdwYwQ9Wm XY7g== X-Gm-Message-State: ABy/qLZQQWTL4tZc7chTr7eTD+PZ26Mz9kphHYoLx4wJFiEZa8qM34Fb KXXdLAC26OYzIsMVM+sGOWy4mW8VBTFb/OX96AJ6cw== X-Received: by 2002:a2e:2403:0:b0:2b9:a63f:6415 with SMTP id k3-20020a2e2403000000b002b9a63f6415mr1059220ljk.5.1690529444707; Fri, 28 Jul 2023 00:30:44 -0700 (PDT) Received: from localhost.localdomain ([2001:861:3382:1a90:792d:7d2b:d7e:14a3]) by smtp.gmail.com with ESMTPSA id y19-20020a7bcd93000000b003fc06169ab3sm6333844wmj.20.2023.07.28.00.30.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jul 2023 00:30:44 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Allow calls to Number_Formals when no formals are present Date: Fri, 28 Jul 2023 09:30:42 +0200 Message-Id: <20230728073042.1852207-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Marc_Poulhi=C3=A8s_via_Gcc-patches?= From: =?utf-8?q?Marc_Poulhi=C3=A8s?= Reply-To: =?utf-8?q?Marc_Poulhi=C3=A8s?= Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1772648766185923996 X-GMAIL-MSGID: 1772648766185923996 From: Piotr Trojanek It is much simpler and safer for the routine Number_Formals to accept subprogram entities that have no formals. gcc/ada/ * einfo-utils.adb (Number_Formals): Change types in body. * einfo-utils.ads (Number_Formals): Change type in spec. * einfo.ads (Number_Formals): Change type in comment. * sem_ch13.adb (Is_Property_Function): Fix style in a caller of Number_Formals that was likely to crash because of missing guards. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/einfo-utils.adb | 4 ++-- gcc/ada/einfo-utils.ads | 2 +- gcc/ada/einfo.ads | 2 +- gcc/ada/sem_ch13.adb | 6 +++++- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/gcc/ada/einfo-utils.adb b/gcc/ada/einfo-utils.adb index dad3a654743..7fe517124d9 100644 --- a/gcc/ada/einfo-utils.adb +++ b/gcc/ada/einfo-utils.adb @@ -2105,8 +2105,8 @@ package body Einfo.Utils is -- Number_Formals -- -------------------- - function Number_Formals (Id : E) return Pos is - N : Int; + function Number_Formals (Id : E) return Nat is + N : Nat; Formal : Entity_Id; begin diff --git a/gcc/ada/einfo-utils.ads b/gcc/ada/einfo-utils.ads index fee771c20f4..20ca470d7ac 100644 --- a/gcc/ada/einfo-utils.ads +++ b/gcc/ada/einfo-utils.ads @@ -227,7 +227,7 @@ package Einfo.Utils is function Next_Stored_Discriminant (Id : E) return Entity_Id; function Number_Dimensions (Id : E) return Pos; function Number_Entries (Id : E) return Nat; - function Number_Formals (Id : E) return Pos; + function Number_Formals (Id : E) return Nat; function Object_Size_Clause (Id : E) return Node_Id; function Parameter_Mode (Id : E) return Formal_Kind; function Partial_Refinement_Constituents (Id : E) return L; diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads index b356b76f0de..d7690d9f88a 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -3832,7 +3832,7 @@ package Einfo is -- Number_Formals (synthesized) -- Applies to subprograms and subprogram types. Yields the number of --- formals as a value of type Pos. +-- formals as a value of type Nat. -- Object_Size_Clause (synthesized) -- Applies to entities for types and subtypes. If an object size clause diff --git a/gcc/ada/sem_ch13.adb b/gcc/ada/sem_ch13.adb index 585c0f33d8b..7cd0800a56c 100644 --- a/gcc/ada/sem_ch13.adb +++ b/gcc/ada/sem_ch13.adb @@ -16544,7 +16544,11 @@ package body Sem_Ch13 is It : Interp; function Is_Property_Function (E : Entity_Id) return Boolean; - -- Implements RM 7.3.4 definition of "property function". + -- Implements RM 7.3.4 definition of "property function" + + -------------------------- + -- Is_Property_Function -- + -------------------------- function Is_Property_Function (E : Entity_Id) return Boolean is begin