===================================================================
@@ -2707,6 +2707,50 @@
end if;
end Find_Optional_Prim_Op;
+ -------------------------------
+ -- Find_Primitive_Operations --
+ -------------------------------
+
+ function Find_Primitive_Operations
+ (T : Entity_Id;
+ Name : Name_Id) return Node_Id
+ is
+ Prim_Elmt : Elmt_Id;
+ Prim_Id : Entity_Id;
+ Ref : Node_Id;
+ Typ : Entity_Id := T;
+
+ begin
+ if Is_Class_Wide_Type (Typ) then
+ Typ := Root_Type (Typ);
+ end if;
+
+ Typ := Underlying_Type (Typ);
+
+ Ref := Empty;
+ Prim_Elmt := First_Elmt (Primitive_Operations (Typ));
+ while Present (Prim_Elmt) loop
+ Prim_Id := Node (Prim_Elmt);
+ if Chars (Prim_Id) = Name then
+
+ -- If this is the first primitive operation found,
+ -- create a reference to it.
+
+ if No (Ref) then
+ Ref := New_Occurrence_Of (Prim_Id, Sloc (T));
+
+ -- Otherwise, add interpretation to existing reference
+
+ else
+ Add_One_Interp (Ref, Prim_Id, Etype (Prim_Id));
+ end if;
+ end if;
+ Next_Elmt (Prim_Elmt);
+ end loop;
+
+ return Ref;
+ end Find_Primitive_Operations;
+
------------------
-- Find_Prim_Op --
------------------
===================================================================
@@ -467,6 +467,13 @@
-- Ada 2005 (AI-251): Given a type T implementing the interface Iface,
-- return the record component containing the tag of Iface.
+ function Find_Primitive_Operations
+ (T : Entity_Id;
+ Name : Name_Id) return Node_Id;
+ -- Return a reference to a primitive operation with given name. If
+ -- operation is overloaded, the node carries the corresponding set
+ -- of overloaded interpretations.
+
function Find_Prim_Op (T : Entity_Id; Name : Name_Id) return Entity_Id;
-- Find the first primitive operation of a tagged type T with name Name.
-- This function allows the use of a primitive operation which is not
===================================================================
@@ -7215,20 +7215,17 @@
-- However, Reference is also a primitive operation of the type, and
-- the inherited operation has a different signature. We retrieve the
- -- right one from the list of primitive operations of the derived type.
+ -- right ones (the function may be overloaded) from the list of
+ -- primitive operations of the derived type.
-- Note that predefined containers are typically all derived from one
-- of the Controlled types. The code below is motivated by containers
-- that are derived from other types with a Reference aspect.
- -- Additional machinery may be needed for types that have several user-
- -- defined Reference operations with different signatures ???
-
elsif Is_Derived_Type (C_Type)
and then Etype (First_Formal (Entity (Func_Name))) /= Etype (Prefix)
then
- Func := Find_Prim_Op (C_Type, Chars (Func_Name));
- Func_Name := New_Occurrence_Of (Func, Loc);
+ Func_Name := Find_Primitive_Operations (C_Type, Chars (Func_Name));
end if;
Assoc := New_List (Relocate_Node (Prefix));