From 33502a3a8ce760840d3e71dfe0dab9910514327e Mon Sep 17 00:00:00 2001 From: Piotr Trojanek Date: Sat, 30 May 2020 20:02:52 +0200 Subject: [PATCH] [Ada] Fix detection of actual parameters for procedure calls gcc/ada/ * sem_ch8.adb (Is_Actual_Parameter): Fix processing when parent is a procedure call statement; extend comment. --- gcc/ada/sem_ch8.adb | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/gcc/ada/sem_ch8.adb b/gcc/ada/sem_ch8.adb index bc52eb05621..08414b2170c 100644 --- a/gcc/ada/sem_ch8.adb +++ b/gcc/ada/sem_ch8.adb @@ -5020,7 +5020,12 @@ package body Sem_Ch8 is -- not know what procedure is being called if the procedure might be -- overloaded, so it is premature to go setting referenced flags or -- making calls to Generate_Reference. We will wait till Resolve_Actuals - -- for that processing + -- for that processing. + -- Note: there is a similar routine Sem_Util.Is_Actual_Parameter, but + -- it works for both function and procedure calls, while here we are + -- only concerned with procedure calls (and with entry calls as well, + -- but they are parsed as procedure calls and only later rewritten to + -- entry calls). function Known_But_Invisible (E : Entity_Id) return Boolean; -- This function determines whether a reference to the entity E, which @@ -5141,15 +5146,24 @@ package body Sem_Ch8 is function Is_Actual_Parameter return Boolean is begin - return - Nkind (N) = N_Identifier - and then - (Nkind (Parent (N)) = N_Procedure_Call_Statement - or else - (Nkind (Parent (N)) = N_Parameter_Association - and then N = Explicit_Actual_Parameter (Parent (N)) - and then Nkind (Parent (Parent (N))) = - N_Procedure_Call_Statement)); + if Nkind (N) = N_Identifier then + case Nkind (Parent (N)) is + when N_Procedure_Call_Statement => + return Is_List_Member (N) + and then List_Containing (N) = + Parameter_Associations (Parent (N)); + + when N_Parameter_Association => + return N = Explicit_Actual_Parameter (Parent (N)) + and then Nkind (Parent (Parent (N))) = + N_Procedure_Call_Statement; + + when others => + return False; + end case; + else + return False; + end if; end Is_Actual_Parameter; ------------------------- -- 2.30.2