From patchwork Fri May 7 09:38:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pierre-Marie de Rodat X-Patchwork-Id: 1475435 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Fc55S17fvz9sj5 for ; Fri, 7 May 2021 19:39:56 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA180383542B; Fri, 7 May 2021 09:38:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from rock.gnat.com (rock.gnat.com [205.232.38.15]) by sourceware.org (Postfix) with ESMTP id 56A3F38930F1 for ; Fri, 7 May 2021 09:38:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 56A3F38930F1 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=derodat@adacore.com Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 4B4D756367; Fri, 7 May 2021 05:38:26 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at gnat.com Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id kgyJfB1d8scN; Fri, 7 May 2021 05:38:26 -0400 (EDT) Received: from tron.gnat.com (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) by rock.gnat.com (Postfix) with ESMTP id C787556369; Fri, 7 May 2021 05:38:23 -0400 (EDT) Received: by tron.gnat.com (Postfix, from userid 4862) id C6C30FA; Fri, 7 May 2021 05:38:23 -0400 (EDT) Date: Fri, 7 May 2021 05:38:23 -0400 From: Pierre-Marie de Rodat To: gcc-patches@gcc.gnu.org Subject: [Ada] Fix link from body protected entry implementation to source code Message-ID: <20210507093823.GA140811@adacore.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Spam-Status: No, score=-12.5 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Cc: Piotr Trojanek Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" CodePeer needs to recognize internally generated procedures that implement protected entries. Previously this was done with an extra field in the procedure entity; now it is done with an extra field in the procedure body. The new field bypasses the trouble with the procedure entity changing its type from E_Void to E_Procedure to E_Subprogram_Body. Also, it is closer to similar flags like Is_Protected_Subprogram_Body and Is_Task_Body_Procedure. Finally, the new field links bodies just like the old field linked entities. Tested on x86_64-pc-linux-gnu, committed on trunk gcc/ada/ * einfo.ads: Move Corresponding_Protected_Entry... * sinfo.ads: ... here. * exp_ch9.adb (Build_Entry_Body): Link procedure and entry bodies. * gen_il-fields.ads (Opt_Field_Enum): Add Corresponding_Entry_Body field to nodes; remove Corresponding_Protected_Entry field from entities. * gen_il-gen-gen_entities.adb (Gen_Entities): Remove Corresponding_Protected_Entry field from E_Void and E_Subprogram_Body. * gen_il-gen-gen_nodes.adb (Gen_Nodes): Add Corresponding_Entry_Body field to N_Subprogram_Body. * sem_ch6.adb (Analyze_Subprogram_Specification): Remove manipulation of Ekind and Corresponding_Protected_Entry added as part of the support for varsize-nodes. diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -786,10 +786,6 @@ package Einfo is -- Modify_Tree_For_C is set. Denotes the internally built procedure -- with an extra out parameter created for it. --- Corresponding_Protected_Entry (Node18) --- Defined in subprogram bodies. Set for subprogram bodies that implement --- a protected type entry to point to the entity for the entry. - -- Corresponding_Record_Component (Node21) -- Defined in components of a derived untagged record type, including -- discriminants. For a regular component or a girder discriminant, diff --git a/gcc/ada/exp_ch9.adb b/gcc/ada/exp_ch9.adb --- a/gcc/ada/exp_ch9.adb +++ b/gcc/ada/exp_ch9.adb @@ -3779,10 +3779,6 @@ package body Exp_Ch9 is raise Program_Error; end case; - -- Establish link between subprogram body entity and source entry - - Set_Corresponding_Protected_Entry (Bod_Id, Ent); - -- Create body of entry procedure. The renaming declarations are -- placed ahead of the block that contains the actual entry body. @@ -3816,6 +3812,10 @@ package body Exp_Ch9 is New_Occurrence_Of (RTE (RE_Get_GNAT_Exception), Loc))))))))); + -- Establish link between subprogram body and source entry body + + Set_Corresponding_Entry_Body (Proc_Body, N); + Reset_Scopes_To (Proc_Body, Protected_Body_Subprogram (Ent)); return Proc_Body; end if; diff --git a/gcc/ada/gen_il-fields.ads b/gcc/ada/gen_il-fields.ads --- a/gcc/ada/gen_il-fields.ads +++ b/gcc/ada/gen_il-fields.ads @@ -113,6 +113,7 @@ package Gen_IL.Fields is Convert_To_Return_False, Corresponding_Aspect, Corresponding_Body, + Corresponding_Entry_Body, Corresponding_Formal_Spec, Corresponding_Generic_Association, Corresponding_Integer_Value, @@ -464,7 +465,6 @@ package Gen_IL.Fields is Corresponding_Equality, Corresponding_Function, Corresponding_Procedure, - Corresponding_Protected_Entry, Corresponding_Record_Component, Corresponding_Record_Type, Corresponding_Remote_Type, diff --git a/gcc/ada/gen_il-gen-gen_entities.adb b/gcc/ada/gen_il-gen-gen_entities.adb --- a/gcc/ada/gen_il-gen-gen_entities.adb +++ b/gcc/ada/gen_il-gen-gen_entities.adb @@ -244,7 +244,6 @@ begin -- Gen_IL.Gen.Gen_Entities Sm (Scope_Depth_Value, Uint), Sm (SPARK_Pragma, Node_Id), Sm (SPARK_Pragma_Inherited, Flag), - Sm (Corresponding_Protected_Entry, Node_Id), -- setter only Sm (Current_Value, Node_Id), -- setter only Sm (Has_Predicates, Flag), -- setter only Sm (Initialization_Statements, Node_Id), -- setter only @@ -1245,7 +1244,6 @@ begin -- Gen_IL.Gen.Gen_Entities Cc (E_Subprogram_Body, Entity_Kind, (Sm (Anonymous_Masters, Elist_Id), Sm (Contract, Node_Id), - Sm (Corresponding_Protected_Entry, Node_Id), Sm (Extra_Formals, Node_Id), Sm (First_Entity, Node_Id), Sm (Ignore_SPARK_Mode_Pragmas, Flag), diff --git a/gcc/ada/gen_il-gen-gen_nodes.adb b/gcc/ada/gen_il-gen-gen_nodes.adb --- a/gcc/ada/gen_il-gen-gen_nodes.adb +++ b/gcc/ada/gen_il-gen-gen_nodes.adb @@ -790,6 +790,7 @@ begin -- Gen_IL.Gen.Gen_Nodes Sy (Bad_Is_Detected, Flag), Sm (Activation_Chain_Entity, Node_Id), Sm (Acts_As_Spec, Flag), + Sm (Corresponding_Entry_Body, Node_Id), Sm (Do_Storage_Check, Flag), Sm (Has_Relative_Deadline_Pragma, Flag), Sm (Is_Entry_Barrier_Function, Flag), diff --git a/gcc/ada/sem_ch6.adb b/gcc/ada/sem_ch6.adb --- a/gcc/ada/sem_ch6.adb +++ b/gcc/ada/sem_ch6.adb @@ -5789,21 +5789,8 @@ package body Sem_Ch6 is if Nkind (N) = N_Function_Specification then Set_Ekind (Designator, E_Function); Set_Mechanism (Designator, Default_Mechanism); - else - case Ekind (Designator) is - when E_Subprogram_Body | E_Void => - Reinit_Field_To_Zero - (Designator, Corresponding_Protected_Entry); - Set_Ekind (Designator, E_Procedure); - - when E_Procedure | E_Generic_Procedure => - null; - - when others => - pragma Assert (False); - end case; - + Set_Ekind (Designator, E_Procedure); Set_Etype (Designator, Standard_Void_Type); end if; diff --git a/gcc/ada/sinfo.ads b/gcc/ada/sinfo.ads --- a/gcc/ada/sinfo.ads +++ b/gcc/ada/sinfo.ads @@ -1040,6 +1040,10 @@ package Sinfo is -- to the defining entity for the corresponding body (NOT the node for -- the body itself). + -- Corresponding_Entry_Body + -- Defined in N_Subprogram_Body. Set for subprogram bodies that implement + -- a protected type entry; points to the body for the entry. + -- Corresponding_Formal_Spec (Node3-Sem) -- This field is set in subprogram renaming declarations, where it points -- to the defining entity for a formal subprogram in the case where the