From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1914) id 1BB943815FF0; Mon, 30 May 2022 08:31:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1BB943815FF0 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Pierre-Marie de Rodat To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-849] [Ada] Fix expansion of structural subprogram variants X-Act-Checkin: gcc X-Git-Author: Piotr Trojanek X-Git-Refname: refs/heads/master X-Git-Oldrev: 263cb16b7667ba92fbac3098375aecfb7f80105e X-Git-Newrev: 576b7778915c1e2da8d50c8f24c5c9b5282eac5f Message-Id: <20220530083154.1BB943815FF0@sourceware.org> Date: Mon, 30 May 2022 08:31:54 +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: Mon, 30 May 2022 08:31:54 -0000 https://gcc.gnu.org/g:576b7778915c1e2da8d50c8f24c5c9b5282eac5f commit r13-849-g576b7778915c1e2da8d50c8f24c5c9b5282eac5f Author: Piotr Trojanek Date: Wed Apr 27 17:30:59 2022 +0200 [Ada] Fix expansion of structural subprogram variants When implementing structural subprogram variants we ignored them in expansion of the pragma itself, but not in expansion of a recursive subprogram call. Now fixed. gcc/ada/ * exp_ch6.adb (Check_Subprogram_Variant): Ignore structural variants. Diff: --- gcc/ada/exp_ch6.adb | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index 44d198798c6..7d507271428 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -3298,19 +3298,33 @@ package body Exp_Ch6 is Variant_Prag : constant Node_Id := Get_Pragma (Current_Scope, Pragma_Subprogram_Variant); + Pragma_Arg1 : Node_Id; Variant_Proc : Entity_Id; begin if Present (Variant_Prag) and then Is_Checked (Variant_Prag) then - -- Analysis of the pragma rewrites its argument with a reference - -- to the internally generated procedure. + Pragma_Arg1 := + Expression (First (Pragma_Argument_Associations (Variant_Prag))); - Variant_Proc := - Entity - (Expression - (First - (Pragma_Argument_Associations (Variant_Prag)))); + -- If pragma parameter is still an aggregate, it comes from a + -- structural variant, which is not expanded and ignored for + -- run-time execution. + + if Nkind (Pragma_Arg1) = N_Aggregate then + pragma Assert + (Chars + (First + (Choices + (First (Component_Associations (Pragma_Arg1))))) = + Name_Structural); + return; + end if; + + -- Otherwise, analysis of the pragma rewrites its argument with a + -- reference to the internally generated procedure. + + Variant_Proc := Entity (Pragma_Arg1); Insert_Action (Call_Node, Make_Procedure_Call_Statement (Loc,