From patchwork Tue May 16 08:39:25 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: 94515 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp270086vqo; Tue, 16 May 2023 01:41:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4cOEdeNXxUenUHvY60HU5A5SbM0DZ2CJdqorlzyZlNypY0Ivbn1QhHodY1jecEjZlwkY5P X-Received: by 2002:a50:ef05:0:b0:50d:682d:d431 with SMTP id m5-20020a50ef05000000b0050d682dd431mr29064010eds.16.1684226486698; Tue, 16 May 2023 01:41:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684226486; cv=none; d=google.com; s=arc-20160816; b=LXpidRXOSfaXz8Q2N/VufLMEMEB6+3tB3OQRO0GkFD8/Rdgc4pEiqRsRxpempR3sIa d0wO0GQe8J6MtWY0x3BcBKFVvsrZK0A31b4hk/m3KTKb1P7SgKQWthHQUej+H5GhoNx5 2aowLP2fScpnEFWy+Z5zvsU/o875LBGqsqUu2b/LVO8Z2UE8s719f1xl79xhk0blMziQ TntMG+fv56D/ABoHNWr3MJwiQpNAlC1Bi7SsjkGMCCrba4RTITVqd+f6y0cZsCPIy/hF m6f6j25SAPCXTDkU/sdInVU69kHI3od/r62DlR7howazk5B3REuf4ftFx+EzkmWjwRMi J1ow== 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=/fwa6z4X7CAPMR0n3lJqsx2mWLr1Pw7CeV0xLbblQaI=; b=iCMcXCQ7tj15HFkqyDud3MS2Cw0jWRuzn0e57BQyzhOYGOSTHElEnhmCPAw9I5pCrK TC22bgRae6VaMDvKzm79BzjHwOa5dTsknIumm6J/GihYyny8tTPWr9ZPF7KNiW7UCfU3 nBXrh00QujVG6stF18KDjBDlozmdJDirDVvxzt9IJ86+cQbBb9XANYfMEPA/VNuFdwQb tUl3ukrirTMXA+YELguDUhd1fNaV4Wa7sv/GVGZNNrAWOHE389EaTHXAqHgdGX3B26S4 q4xtdkxwSgUTJ7nWTH7P80UmV3vyM114iFwPL01X92FWwk1buhqThoy1QKew+Je0TfKu KmxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=dJAGiO0J; 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 sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id f10-20020a056402160a00b0050ca8ca3250si13492498edv.418.2023.05.16.01.41.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 01:41:26 -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=dJAGiO0J; 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 6BC90385354F for ; Tue, 16 May 2023 08:40:25 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BC90385354F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684226425; bh=/fwa6z4X7CAPMR0n3lJqsx2mWLr1Pw7CeV0xLbblQaI=; h=To:Cc:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=dJAGiO0JmwX/lOjM46lTCANWEv1X0JVGVhhmJSTM7gNeqwN5s5rk2lH56hzixvWzo Sm23Eq79eQyfjhDupisxr/1Jlur3YL2RsD7uHB+oDPHvM0DXOfvUn8i4mfEnU7GRUG W+O0mKAVBuPCk1gjACvGkmIgNvvbSLKOHwWK9guE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id C62743857017 for ; Tue, 16 May 2023 08:39:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C62743857017 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-3062c1e7df8so9136726f8f.1 for ; Tue, 16 May 2023 01:39:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684226367; x=1686818367; 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=/fwa6z4X7CAPMR0n3lJqsx2mWLr1Pw7CeV0xLbblQaI=; b=RhLzqnIYhNSvVxUyH3dtDTsEDKCj+q8S7jGYIRieE2+GHxwz8uTXYkapGIoPhkPgni OTBCNDZqGJBXgky2+9GGDnEuQFKDdgUq1RVGMOLVah2gcLB+5RfxE4B8Z5l0/DXISahV dPJwdwZTJxdr+h/+UuPB4ADSOqBhxl79mDqrPLV7apw1DGVoEpqZqL/cWkJ33/LEbDpW b98sDLd3lFedlrslSsaCYpLgqpNed7BfWZxfD3sC1k4ft0JLHHXNq9DExSA8TXhE5ksJ rlqELV0XTWxeBvWT0ZIACAdWnp4wo9SPPukk8Xn4ZsSknYQEVKk34X9FzVPZbviO30rf rokA== X-Gm-Message-State: AC+VfDwcHAwW9xcMk/UxPKgaUVw7MsGaDIH69Lfh5eizXgIPBA28qPeY NrdGMk3b00/gdvK54BoRc5A7EIjzJeOiEQCwtn1Mtw== X-Received: by 2002:a5d:590a:0:b0:306:43ad:b34e with SMTP id v10-20020a5d590a000000b0030643adb34emr28168481wrd.18.1684226367657; Tue, 16 May 2023 01:39:27 -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 l8-20020a5d4108000000b003077f3dfcc8sm1789933wrp.32.2023.05.16.01.39.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 May 2023 01:39:27 -0700 (PDT) To: gcc-patches@gcc.gnu.org Cc: =?utf-8?q?Marc_Poulhi=C3=A8s?= Subject: [COMMITTED] ada: Trivial refactoring in Instantiate_*_Body Date: Tue, 16 May 2023 10:39:25 +0200 Message-Id: <20230516083925.1500745-1-poulhies@adacore.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 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?1766039472390531516?= X-GMAIL-MSGID: =?utf-8?q?1766039472390531516?= Factor out Par_Vis/Install_Parent/Par_Installed in Instantiate_Package_Body and Instantiate_Subprogram_Body. gcc/ada/ * sem_ch12.adb (Instantiate_Package_Body): Simplify if/then/else. (Instantiate_Subprogram_Body): Likewise. Tested on x86_64-pc-linux-gnu, committed on master. --- gcc/ada/sem_ch12.adb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/gcc/ada/sem_ch12.adb b/gcc/ada/sem_ch12.adb index 39ceaf7c16f..c4cc641c68c 100644 --- a/gcc/ada/sem_ch12.adb +++ b/gcc/ada/sem_ch12.adb @@ -12175,9 +12175,6 @@ package body Sem_Ch12 is and then Nkind (Gen_Id) = N_Expanded_Name then Par_Ent := Entity (Prefix (Gen_Id)); - Par_Vis := Is_Immediately_Visible (Par_Ent); - Install_Parent (Par_Ent, In_Body => True); - Par_Installed := True; elsif Ekind (Scope (Gen_Unit)) = E_Generic_Package and then Ekind (Scope (Act_Decl_Id)) = E_Package @@ -12189,12 +12186,12 @@ package body Sem_Ch12 is Par_Ent := Entity (Prefix (Name (Get_Unit_Instantiation_Node (Scope (Act_Decl_Id))))); - Par_Vis := Is_Immediately_Visible (Par_Ent); - Install_Parent (Par_Ent, In_Body => True); - Par_Installed := True; elsif Is_Child_Unit (Gen_Unit) then Par_Ent := Scope (Gen_Unit); + end if; + + if Present (Par_Ent) then Par_Vis := Is_Immediately_Visible (Par_Ent); Install_Parent (Par_Ent, In_Body => True); Par_Installed := True; @@ -12611,12 +12608,11 @@ package body Sem_Ch12 is and then Nkind (Gen_Id) = N_Expanded_Name then Par_Ent := Entity (Prefix (Gen_Id)); - Par_Vis := Is_Immediately_Visible (Par_Ent); - Install_Parent (Par_Ent, In_Body => True); - Par_Installed := True; - elsif Is_Child_Unit (Gen_Unit) then Par_Ent := Scope (Gen_Unit); + end if; + + if Present (Par_Ent) then Par_Vis := Is_Immediately_Visible (Par_Ent); Install_Parent (Par_Ent, In_Body => True); Par_Installed := True;