diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2020-03-18 18:38:12 +0100 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2020-06-12 04:29:18 -0400 |
commit | 052d6488478db2b3c55d165aac653dc63582e38b (patch) | |
tree | 73083d7b5907156e4824af7bc98df3a262023f06 /gcc | |
parent | 879f6fa876b5b66f547a4b426145575433468572 (diff) | |
download | gcc-052d6488478db2b3c55d165aac653dc63582e38b.zip gcc-052d6488478db2b3c55d165aac653dc63582e38b.tar.gz gcc-052d6488478db2b3c55d165aac653dc63582e38b.tar.bz2 |
[Ada] Remove redundant iterations in checks for overlapping actuals
2020-06-12 Piotr Trojanek <trojanek@adacore.com>
gcc/ada/
* sem_warn.adb (Warn_On_Overlapping_Actuals): Simplify.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ada/sem_warn.adb | 102 |
1 files changed, 42 insertions, 60 deletions
diff --git a/gcc/ada/sem_warn.adb b/gcc/ada/sem_warn.adb index 415aaee..fab512a 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 - ("<<writable actual for & overlaps with " - & "actual for&", Act1, Form); - end if; + 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, Form2); else -- For greater clarity, give name of formal - Error_Msg_Node_2 := Form; - - -- This is one of the messages - + Error_Msg_Node_2 := Form2; Error_Msg_FE ("<<writable actual for & overlaps with " - & "actual for&", Act1, Form1); + & "actual for&", Act1, Form2); end if; - end; + + else + -- For greater clarity, give name of formal + + Error_Msg_Node_2 := Form2; + + -- This is one of the messages + + Error_Msg_FE + ("<<writable actual for & overlaps with " + & "actual for&", Act1, Form1); + end if; end if; end if; |