From patchwork Mon May 29 08:29:12 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: 100152 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1363841vqr; Mon, 29 May 2023 01:38:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ78w9PqBQ7xZprRIQu2yM9Vlp1Vg+k1VZifA6sZy0dhGsi+Y9HgOs9EeoiIzOgGzFTMapUg X-Received: by 2002:a17:907:1627:b0:96f:d67b:80af with SMTP id hb39-20020a170907162700b0096fd67b80afmr11687511ejc.75.1685349526792; Mon, 29 May 2023 01:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685349526; cv=none; d=google.com; s=arc-20160816; b=Oas3QiBD0AvXNBItuAL4TSAKkYTS5oZvnJ/MfJVchXik2YZ11cAlvLr+1it4nS/iMY DS/Yn6jtStOxOT8gJ6rlSrkUScYpC+P3W1jSdSnCtYmUKY4Ihaco5olYEOHcfCmnxfm8 EN5R/9KW+iEh79/g0EJD+zTIxuCRCl7Lm5CqHDsYQiZvMoFqNgR43l7T2Oo5lEmH3yeI I2g8DpJAJ7U60sf+OntHzEbVd1zGjKjQtJ3Xzcq8wONxFa/s8QJdTw2AJTUixFyGKdCS OhPErIRljb4nC0o5EtHM7zTgSkfYOxUkW0gaU9+z4+dEboNBSYgKUJGv/r3nAIjnQMpx EvPw== 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=nu6JPSHoEogT8s2uapLh4tkxP5lqkTySu36oVoEUrms=; b=rcRYemDfA5kgXdhYynOwhu/MDnTDTugrCRLNTt+hED2+onNFkmjDe09Ws99AZHk+4z aagyzP5oxQPLeuJaHccanZSqc+R3HQ5Mo5l0HJ90FCER2/Pe9jDFNXBXAERyWmYwSNYb JbLLlSf/fajyKaMUG3HeWcKRHQ+ndCi77uZ4nouFgYev+1x5nxhcMHPnzq5MU1L+qrww xmwmzx22dIcSS0MpopPDMedUl9KUoXEtQevROlVqrWNxxp4PLWpxakbW3R4q7eMvetWn 8tHKs+sAhLzhSFEMe4xmHWUUa0cwmwNtqjInpVmAbT/MT0pFdtAd0wLWIT6ozdI/d7dl TZiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=sVAmyHPF; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id p13-20020a170906604d00b009661ed2f429si6502814ejj.770.2023.05.29.01.38.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 01:38:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=sVAmyHPF; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c 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 37AAE3940CF7 for ; Mon, 29 May 2023 08:34:26 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37AAE3940CF7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685349266; bh=nu6JPSHoEogT8s2uapLh4tkxP5lqkTySu36oVoEUrms=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=sVAmyHPFdSbzr3qxH2EjmjJnSb++D0OiiEy6PKbqP+5LXj8AFc8zcKEwUDjfQOVwH uc2hwZtJpi7iL/9lRcx9KEjZmgWt7CpO10E9zA7DM9BlhA3XZBVj+xLqOnF6bQMqwR IkBVrQU9WlMlfHvnsIWIVEqCXzGw7+hRnZG2DKSQ= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by sourceware.org (Postfix) with ESMTPS id 28CA03856DD6 for ; Mon, 29 May 2023 08:29:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 28CA03856DD6 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-3f61530506aso31648125e9.1 for ; Mon, 29 May 2023 01:29:14 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685348953; x=1687940953; 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=nu6JPSHoEogT8s2uapLh4tkxP5lqkTySu36oVoEUrms=; b=BUQrGNMbkj1hpdJTVuRPKXH16JS0yQpO+5orKmYzvc83Ounw4AxTeoQNbi0ILVN/+2 w5YhLcdZXzA5ninyCwwEf6utPdaeoY7tgJPXmyW94IZ1NKbdBqGq+UHo39NdHgKvScC+ rW/K75U37wQpbSmV3dpCEeURV2UENNNKCXjvxPZFuXqllAgdsr5jppHbQY8pCBBLW7IP 3Zf+87h9xEldDT3li8vVf3/KPu9tCflkGI7idEoRtIOp6U0IBVy8lDIpwL5M+lUvR9sN VEGuR6P+8RZBDg6KR+EGp5fbOXzsjMCQGmRE/ve86CdnwJuZ5kVRT5016QD/DkTaBGPf 1Viw== X-Gm-Message-State: AC+VfDxS3ISw2bsgwH4zs1g2nc5wosDDV6MG9AS3HCcIDdiEwrkoGQK3 gGHWGlKy1xUrYEKQmuMpLMqZi6ZimarU8Xn34/MhOw== X-Received: by 2002:a7b:cc8e:0:b0:3f4:2b98:428f with SMTP id p14-20020a7bcc8e000000b003f42b98428fmr8588576wma.39.1685348953836; Mon, 29 May 2023 01:29:13 -0700 (PDT) Received: from poulhies-Precision-5550.telnowedge.local (lmontsouris-659-1-24-67.w81-250.abo.wanadoo.fr. [81.250.175.67]) by smtp.gmail.com with ESMTPSA id m17-20020a056000009100b0030ae973c2e7sm3333589wrx.83.2023.05.29.01.29.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 May 2023 01:29:13 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: Piotr Trojanek Subject: [COMMITTED] ada: Reuse routine for getting from body entity to spec entity Date: Mon, 29 May 2023 10:29:12 +0200 Message-Id: <20230529082912.2409765-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: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767217065233462936?= X-GMAIL-MSGID: =?utf-8?q?1767217065233462936?= From: Piotr Trojanek Cleanup related to handling of access-to-subprogram types with Pre and Post aspects. Behavior is unaffected. gcc/ada/ * sem_util.adb (Check_Result_And_Post_State): Replace low-level navigation with a high-level Unique_Entity. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_util.adb | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb index d71329bbcb2..64abfb11ce5 100644 --- a/gcc/ada/sem_util.adb +++ b/gcc/ada/sem_util.adb @@ -4546,13 +4546,12 @@ package body Sem_Util is -- Local variables Items : constant Node_Id := Contract (Subp_Id); - Subp_Decl : constant Node_Id := Unit_Declaration_Node (Subp_Id); Case_Prag : Node_Id := Empty; Post_Prag : Node_Id := Empty; Prag : Node_Id; Seen_In_Case : Boolean := False; Seen_In_Post : Boolean := False; - Spec_Id : Entity_Id; + Spec_Id : constant Entity_Id := Unique_Entity (Subp_Id); -- Start of processing for Check_Result_And_Post_State @@ -4570,25 +4569,6 @@ package body Sem_Util is return; end if; - -- Retrieve the entity of the subprogram spec (if any) - - if Nkind (Subp_Decl) = N_Subprogram_Body - and then Present (Corresponding_Spec (Subp_Decl)) - then - Spec_Id := Corresponding_Spec (Subp_Decl); - - elsif Nkind (Subp_Decl) = N_Subprogram_Body_Stub - and then Present (Corresponding_Spec_Of_Stub (Subp_Decl)) - then - Spec_Id := Corresponding_Spec_Of_Stub (Subp_Decl); - - elsif Nkind (Subp_Decl) = N_Entry_Body then - Spec_Id := Corresponding_Spec (Subp_Decl); - - else - Spec_Id := Subp_Id; - end if; - -- Examine all postconditions for attribute 'Result and a post-state Prag := Pre_Post_Conditions (Items);