From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 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-wr1-x435.google.com with SMTP id ffacd0b85a97d-3062c1e7df8so9136726f8f.1 for ; Tue, 16 May 2023 01:39:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1684226367; x=1686818367; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/fwa6z4X7CAPMR0n3lJqsx2mWLr1Pw7CeV0xLbblQaI=; b=KJnezSRdX6ajlYsHvtkBmEzdRUfmgc2MAtsockgnsNqPKgNlo1rQcluFPrRVXFAaVh nTI5JCLLgpXavyAda5XtC2M0uEvezMi3S8H/nQX+jUc2GKMgjmamkR9/pTf6PCuxBsJi Bwe0KJskYc1Q+gWbBmCGWqjF7f9p21H/Irgu0XEWgZ3BPFjZTguL9FSrJupX9VmfQh5p SHNcxbwbjsnqcZ9VUUap1aQs4fa1NwKRKUcCaNM28qEwMpDtPYvwbGkB6XrGzZDfXP25 Nxcm0kDc/Jsgy1z6DgQZh1XYdpFjo8hT0f4meITQEzyGVjx0rv+10FfDQ/ieNTdsnMMj dw0w== 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-Google-Smtp-Source: ACHHUZ7+jE7FtbDveP6CQaCom4PV6nfwZXGOLFqOJamlFNLI3xTm1myjh2seeiQeOhqO2xWjFTpZPg== 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) From: =?UTF-8?q?Marc=20Poulhi=C3=A8s?= To: gcc-patches@gcc.gnu.org Cc: =?UTF-8?q?Marc=20Poulhi=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 Content-Transfer-Encoding: 8bit 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 List-Id: 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; -- 2.40.0