When iterating over actual and formal parameters, we should use
First_Actual/Next_Actual and not simply First/Next, because the
order of actual parameters might be different than the order of
formal parameters obtained with First_Formal/Next_Formal.
This patch fixes a glitch in validity checks for actual parameters
and applies the same fix to other misuses of First/Next as well.
gcc/ada/
* checks.adb (Ensure_Valid): Use First_Actual/Next_Actual.
* exp_ch6.adb (Is_Direct_Deep_Call): Likewise.
* exp_util.adb (Type_Of_Formal): Likewise.
* sem_util.adb (Is_Container_Element): Likewise; cleanup
membership test by using a subtype.
-- OUT parameter for which we are the argument.
F := First_Formal (E);
- A := First (L);
+ A := First_Actual (P);
while Present (F) loop
if A = N
and then (Ekind (F) = E_Out_Parameter
end if;
Next_Formal (F);
- Next (A);
+ Next_Actual (A);
end loop;
end if;
end if;
Formal : Entity_Id;
begin
- Actual := First (Parameter_Associations (Call_Node));
+ Actual := First_Actual (Call_Node);
Formal := First_Formal (Subp);
while Present (Actual)
and then Present (Formal)
return True;
end if;
- Next (Actual);
+ Next_Actual (Actual);
Next_Formal (Formal);
end loop;
end;
begin
-- Examine the list of actual and formal parameters in parallel
- A := First (Parameter_Associations (Call));
+ A := First_Actual (Call);
F := First_Formal (Entity (Name (Call)));
while Present (A) and then Present (F) loop
if A = Actual then
return Etype (F);
end if;
- Next (A);
+ Next_Actual (A);
Next_Formal (F);
end loop;
elsif Nkind (Parent (Par)) = N_Object_Renaming_Declaration then
return False;
- elsif Nkind (Parent (Par)) in
- N_Function_Call |
- N_Procedure_Call_Statement |
- N_Entry_Call_Statement
+ elsif Nkind (Parent (Par)) in N_Entry_Call_Statement
+ | N_Subprogram_Call
then
-- Check that the element is not part of an actual for an
-- in-out parameter.
begin
F := First_Formal (Entity (Name (Parent (Par))));
- A := First (Parameter_Associations (Parent (Par)));
+ A := First_Actual (Parent (Par));
while Present (F) loop
if A = Par and then Ekind (F) /= E_In_Parameter then
return False;
end if;
Next_Formal (F);
- Next (A);
+ Next_Actual (A);
end loop;
end;