From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2100) id D5C13388E828; Sat, 22 Aug 2020 21:49:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D5C13388E828 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1598132983; bh=vmTeCXojjOtEOrgn5cDj0Nq7T/c5Im1zyMbFjHMvKXk=; h=From:To:Subject:Date:From; b=T/BKp25ERRvSRG85CkmOCDqeocIf3nh/L3FsZlNPSN342/SkeFWBir8/k7xWuBY0p 5uvGgu2J6msQKzq52uUz+I09nevLJAvCagYzqun/7OQ8q5xHHRaB91zkm6Zo1gH0da BHNrl7chTbFuvT5gexuvqNfJuW/c8B0PzmTcz1zg= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Giuliano Belinassi To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/autopar_devel] [Ada] Accept objects from nested packages in Initializes contract X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/devel/autopar_devel X-Git-Oldrev: 78658ff595c7a520cc7f45bd48946650bfacd437 X-Git-Newrev: ab12df2589c52ae68f3c1927d3345770dc1eb4c0 Message-Id: <20200822214943.D5C13388E828@sourceware.org> Date: Sat, 22 Aug 2020 21:49:43 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Aug 2020 21:49:43 -0000 https://gcc.gnu.org/g:ab12df2589c52ae68f3c1927d3345770dc1eb4c0 commit ab12df2589c52ae68f3c1927d3345770dc1eb4c0 Author: Piotr Trojanek Date: Thu Oct 31 13:38:17 2019 +0100 [Ada] Accept objects from nested packages in Initializes contract 2020-06-02 Piotr Trojanek gcc/ada/ * sem_prag.adb (Collect_States_And_Objects): Call itself on declaration of nested packages; append abstract states one-by-one, so that in recursive call we do not overwrite the ones that have been already collected. Diff: --- gcc/ada/sem_prag.adb | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/gcc/ada/sem_prag.adb b/gcc/ada/sem_prag.adb index 7aa48b5a876..9dff1ce05b0 100644 --- a/gcc/ada/sem_prag.adb +++ b/gcc/ada/sem_prag.adb @@ -2897,7 +2897,7 @@ package body Sem_Prag is -- Verify the legality of a single initialization item followed by a -- list of input items. - procedure Collect_States_And_Objects; + procedure Collect_States_And_Objects (Pack_Decl : Node_Id); -- Inspect the visible declarations of the related package and gather -- the entities of all abstract states and objects in States_And_Objs. @@ -3166,15 +3166,21 @@ package body Sem_Prag is -- Collect_States_And_Objects -- -------------------------------- - procedure Collect_States_And_Objects is - Pack_Spec : constant Node_Id := Specification (Pack_Decl); - Decl : Node_Id; + procedure Collect_States_And_Objects (Pack_Decl : Node_Id) is + Pack_Spec : constant Node_Id := Specification (Pack_Decl); + Pack_Id : constant Entity_Id := Defining_Entity (Pack_Decl); + Decl : Node_Id; + State_Elmt : Elmt_Id; begin -- Collect the abstract states defined in the package (if any) - if Present (Abstract_States (Pack_Id)) then - States_And_Objs := New_Copy_Elist (Abstract_States (Pack_Id)); + if Has_Non_Null_Abstract_State (Pack_Id) then + State_Elmt := First_Elmt (Abstract_States (Pack_Id)); + while Present (State_Elmt) loop + Append_New_Elmt (Node (State_Elmt), States_And_Objs); + Next_Elmt (State_Elmt); + end loop; end if; -- Collect all objects that appear in the visible declarations of the @@ -3189,6 +3195,9 @@ package body Sem_Prag is then Append_New_Elmt (Defining_Entity (Decl), States_And_Objs); + elsif Nkind (Decl) = N_Package_Declaration then + Collect_States_And_Objects (Decl); + elsif Is_Single_Concurrent_Type_Declaration (Decl) then Append_New_Elmt (Anonymous_Object (Defining_Entity (Decl)), @@ -3228,7 +3237,7 @@ package body Sem_Prag is -- Initialize the various lists used during analysis - Collect_States_And_Objects; + Collect_States_And_Objects (Pack_Decl); if Present (Expressions (Inits)) then Init := First (Expressions (Inits));