if Present (Formal_Of_Actual) then
Replace_Type (Formal_Of_Actual, New_Formal);
Next_Formal (Formal_Of_Actual);
+
+ -- Do not replace the type when Derived_Type inherits the first
+ -- controlling parameter aspect and this is not the first formal
+ -- of this operation. The exception to this common case is when
+ -- this is a controlling formal; this case corresponds with an
+ -- inherited operation of an ancestor that does not have the
+ -- first controlling parameter aspect.
+
+ elsif Is_Tagged_Type (Parent_Type)
+ and then Has_First_Controlling_Parameter_Aspect (Parent_Type)
+ and then Formal /= First_Formal (Parent_Subp)
+ and then not Is_Controlling_Formal (Formal)
+ and then Is_Dispatching_Operation (Parent_Subp)
+ and then not Is_Predefined_Dispatching_Operation (Parent_Subp)
+ then
+ null;
+
else
Replace_Type (Formal, New_Formal);
end if;
(Typ : Entity_Id;
Subp : Entity_Id)
is
- Formal : Entity_Id;
- Ctrl_Type : Entity_Id;
+ Ctrl_Type : Entity_Id;
+ Formal : Entity_Id;
+ Ovr_Formal : Entity_Id := Empty;
begin
-- We skip the check for thunks
return;
end if;
+ if Present (Overridden_Operation (Subp)) then
+ Ovr_Formal := First_Formal (Overridden_Operation (Subp));
+ end if;
+
Formal := First_Formal (Subp);
while Present (Formal) loop
Ctrl_Type := Empty;
(Ekind (Subp) = E_Function
and then Is_Operator_Name (Chars (Subp)))
then
- Ctrl_Type := Check_Controlling_Type (Etype (Formal), Subp);
+ -- Overriding a parent primitive
+
+ if Present (Ovr_Formal)
+ and then not Is_Controlling_Formal (Ovr_Formal)
+ then
+ null;
+ else
+ Ctrl_Type := Check_Controlling_Type (Etype (Formal), Subp);
+ end if;
end if;
if Present (Ctrl_Type) then
end if;
end if;
+ if Present (Overridden_Operation (Subp)) then
+ Next_Formal (Ovr_Formal);
+ end if;
+
Next_Formal (Formal);
end loop;