From: Piotr Trojanek Date: Wed, 18 Mar 2020 17:38:12 +0000 (+0100) Subject: [Ada] Remove redundant iterations in checks for overlapping actuals X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=052d6488478db2b3c55d165aac653dc63582e38b;p=gcc.git [Ada] Remove redundant iterations in checks for overlapping actuals 2020-06-12 Piotr Trojanek gcc/ada/ * sem_warn.adb (Warn_On_Overlapping_Actuals): Simplify. --- diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index 415aaeed920..fab512a5cca 100644 --- a/gcc/ada/sem_warn.adb +++ b/gcc/ada/sem_warn.adb @@ -3750,12 +3750,10 @@ package body Sem_Warn is null; else - Form2 := First_Formal (Subp); - Act2 := First_Actual (N); + Form2 := Next_Formal (Form1); + Act2 := Next_Actual (Act1); while Present (Form2) and then Present (Act2) loop - if Form1 /= Form2 - and then Refer_Same_Object (Act1, Act2) - then + if Refer_Same_Object (Act1, Act2) then if Is_Generic_Type (Etype (Act2)) then return; end if; @@ -3847,71 +3845,55 @@ package body Sem_Warn is or else Error_To_Warning or else Warn_Only; - declare - Act : Node_Id; - Form : Entity_Id; - - begin - -- Find matching actual - - Act := First_Actual (N); - Form := First_Formal (Subp); - while Act /= Act2 loop - Next_Formal (Form); - Next_Actual (Act); - end loop; - - if Is_Elementary_Type (Etype (Act1)) - and then Ekind (Form2) = E_In_Parameter - then - null; -- No real aliasing - - elsif Is_Elementary_Type (Etype (Act2)) - and then Ekind (Form2) = E_In_Parameter - then - null; -- Ditto + if Is_Elementary_Type (Etype (Act1)) + and then Ekind (Form2) = E_In_Parameter + then + null; -- No real aliasing - -- If the call was written in prefix notation, and - -- thus its prefix before rewriting was a selected - -- component, count only visible actuals in call. + elsif Is_Elementary_Type (Etype (Act2)) + and then Ekind (Form2) = E_In_Parameter + then + null; -- Ditto - elsif Is_Entity_Name (First_Actual (N)) - and then Nkind (Original_Node (N)) = Nkind (N) - and then Nkind (Name (Original_Node (N))) = - N_Selected_Component - and then - Is_Entity_Name - (Prefix (Name (Original_Node (N)))) - and then - Entity (Prefix (Name (Original_Node (N)))) = - Entity (First_Actual (N)) - then - if Act1 = First_Actual (N) then - Error_Msg_FE - ("<<`IN OUT` prefix overlaps with " - & "actual for&", Act1, Form); + -- If the call was written in prefix notation, and + -- thus its prefix before rewriting was a selected + -- component, count only visible actuals in call. - else - -- For greater clarity, give name of formal - - Error_Msg_Node_2 := Form; - Error_Msg_FE - ("<