Formal_Typ : constant Entity_Id := Etype (Formal);
Is_Written : constant Boolean := Ekind (Formal) /= E_In_Parameter;
+ Call : Node_Id;
+
begin
-- The expansion depends on Item, the second actual, which is
-- the object being streamed in or out.
-- operation is not inherited), we are all set, and can use the
-- argument unchanged.
- if not Is_Class_Wide_Type (Entity (Pref))
- and then not Is_Class_Wide_Type (Etype (Item))
+ if not Is_Class_Wide_Type (Item_Typ)
+ and then not Is_Class_Wide_Type (Formal_Typ)
and then Base_Type (Item_Typ) /= Base_Type (Formal_Typ)
then
-- Perform an unchecked conversion when either the argument or
-- And now rewrite the call
- Rewrite (N,
- Make_Procedure_Call_Statement (Loc,
- Name => New_Occurrence_Of (Pname, Loc),
- Parameter_Associations => Exprs));
+ Call := Make_Procedure_Call_Statement (Loc,
+ Name => New_Occurrence_Of (Pname, Loc),
+ Parameter_Associations => Exprs);
+
+ -- If the attribute has not been specified for a CW type, then we
+ -- must dispatch to the attribute of the specific type identified
+ -- by the tag of Item.
+
+ if Is_Class_Wide_Type (Entity (Pref))
+ and then Is_Dispatching_Operation (Pname)
+ then
+ Set_Controlling_Argument (Call, Item);
+ end if;
+ Rewrite (N, Call);
Analyze (N);
end Rewrite_Attribute_Proc_Call;
-- Dispatching case with class-wide type
- elsif Is_Class_Wide_Type (P_Type) then
+ elsif Is_Class_Wide_Type (U_Type) then
- if Is_Mutably_Tagged_Type (P_Type) then
+ if Is_Mutably_Tagged_Type (U_Type) then
-- In mutably tagged case, rewrite
-- T'Class'Input (Strm)
end if;
Read_Controlling_Tag (P_Type, Cntrl);
- Fname := Find_Prim_Op (Root_Type (P_Type), TSS_Stream_Input);
+ Fname := Find_Prim_Op (U_Type, TSS_Stream_Input);
-- For tagged types, use the primitive Input function
end if;
-- Tagged type case, use the primitive Put_Image function. Note
- -- that this will dispatch in the class-wide case which is what we
- -- want.
+ -- that this will dispatch in the class-wide case as required.
elsif Is_Tagged_Type (U_Type) then
Pname := Find_Optional_Prim_Op (U_Type, TSS_Put_Image);
end;
-- Tagged type case, use the primitive Read function. Note that
- -- this will dispatch in the class-wide case which is what we want
+ -- this will dispatch in the class-wide case as required.
elsif Is_Tagged_Type (U_Type) then
end;
-- Tagged type case, use the primitive Write function. Note that
- -- this will dispatch in the class-wide case which is what we want
+ -- this will dispatch in the class-wide case as required.
elsif Is_Tagged_Type (U_Type) then