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: 70220 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1B58A3888829 for ; Mon, 29 May 2023 08:34:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1B58A3888829 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685349247; bh=nu6JPSHoEogT8s2uapLh4tkxP5lqkTySu36oVoEUrms=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=sGgdQEdQt7y4Xrw0G8EM0k6kCSgjR270ucKlUjGRGi4pJFltEavOHjhghuStWb4EN GImejH6T0RLYdxtp1eO2mmbsuNP9woSNodapnpuRAOcM6IOQzsvSG2PMx7LoIojtEH hxC0UaaHwHA3bx5yfMa15lZ6HBGVuLWwkX3is9Pg= 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-Google-Smtp-Source: ACHHUZ5RmxSxv58QneeW+aljuqZsz6Jr1Zai31a62WLFqApcOOiaRl5s8w+pFCAG9hmNjWrLfMCOjw== 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+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" 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);