When dispatching in a Default_Initial_Condition, copying the condition
node crashes if there is a, possibly nested, parameterless function as
actual parameter; there were two issues:
1. Subp_Entity in Check_Dispatching_call was uninitialized, a GNAT SAS
finding.
2. The controlling argument update logic only tried to propagate the
update by traversing the actual parameters, leading to a crash in
case of parameterless functions.
This patch initializes Subp_Entity and allows the update of controlling
argument to succeed even when no traversal happened.
gcc/ada/ChangeLog:
* sem_disp.adb (Check_Dispatching_call): Fix uninitialized Subp_Entity.
* sem_util.adb (Update_Controlling_Argument): No need to replace controlling argument
in case of functions.
Formal : Entity_Id;
Control : Node_Id := Empty;
Func : Entity_Id;
- Subp_Entity : Entity_Id;
+ Subp_Entity : constant Entity_Id := Entity (Name (N));
Indeterm_Ctrl_Type : Entity_Id := Empty;
-- Type of a controlling formal whose actual is a tag-indeterminate call
-- Find a controlling argument, if any
if Present (Parameter_Associations (N)) then
- Subp_Entity := Entity (Name (N));
Actual := First_Actual (N);
Formal := First_Formal (Subp_Entity);
Next (Old_Act);
end loop;
- pragma Assert (Replaced);
+ if Nkind (Old_Call) /= N_Function_Call then
+ pragma Assert (Replaced);
+ end if;
end Update_Controlling_Argument;
-------------------------------