or else Has_Task (Base_Type (Ctype))
then
Append_List_To (Stmts,
- Build_Initialization_Call (Loc,
+ Build_Initialization_Call (N,
Id_Ref => Indexed_Comp,
Typ => Ctype,
With_Default_Init => True));
if not Is_Interface (Init_Typ) then
Append_List_To (L,
- Build_Initialization_Call (Loc,
+ Build_Initialization_Call (N,
Id_Ref => Ref,
Typ => Init_Typ,
In_Init_Proc => Within_Init_Proc,
Set_Assignment_OK (Ref);
Append_List_To (L,
- Build_Initialization_Call (Loc,
+ Build_Initialization_Call (N,
Id_Ref => Ref,
Typ => Init_Typ,
In_Init_Proc => Within_Init_Proc,
if Is_CPP_Constructor_Call (Expression (Comp)) then
Append_List_To (L,
- Build_Initialization_Call (Loc,
+ Build_Initialization_Call (N,
Id_Ref =>
Make_Selected_Component (Loc,
Prefix => New_Copy_Tree (Target),
end;
Append_List_To (L,
- Build_Initialization_Call (Loc,
+ Build_Initialization_Call (N,
Id_Ref => Make_Selected_Component (Loc,
Prefix => New_Copy_Tree (Target),
Selector_Name =>
Param := First (Parameter_Associations (Stmt));
Insert_Actions
(Stmt,
- Build_Initialization_Call
- (Sloc (N), New_Copy_Tree (Param), Etype (Param)));
+ Build_Initialization_Call (N,
+ New_Copy_Tree (Param), Etype (Param)));
end if;
Next (Stmt);
Present (Variant_Part (Component_List (Type_Definition (Decl))))
and then Nkind (N) /= N_Extension_Aggregate
then
-
-- Call init proc to set discriminants.
-- There should eventually be a special procedure for this ???
Ref := New_Occurrence_Of (Defining_Identifier (N), Loc);
- Insert_Actions_After (N,
- Build_Initialization_Call (Sloc (N), Ref, Typ));
+ Insert_Actions_After (N, Build_Initialization_Call (N, Ref, Typ));
end if;
end Initialize_Discriminants;
Clean_Task_Names (Comp_Type, Proc_Id);
return
Build_Initialization_Call
- (Loc => Loc,
+ (N => Nod,
Id_Ref => Comp,
Typ => Comp_Type,
In_Init_Proc => True,
end if;
Comp_Init :=
- Build_Initialization_Call (Loc,
+ Build_Initialization_Call (N,
Obj_Ref, Typ, Target_Ref => Target_Ref);
end if;
end if;
-- end;
function Build_Initialization_Call
- (Loc : Source_Ptr;
+ (N : Node_Id;
Id_Ref : Node_Id;
Typ : Entity_Id;
In_Init_Proc : Boolean := False;
Constructor_Ref : Node_Id := Empty;
Init_Control_Actual : Entity_Id := Empty) return List_Id
is
- Res : constant List_Id := New_List;
+ Loc : constant Source_Ptr := Sloc (N);
+ Res : constant List_Id := New_List;
Full_Type : Entity_Id;
-- Add discriminant values if discriminants are present
if Has_Discriminants (Full_Init_Type) then
+ -- If an allocated object will be constrained by the default
+ -- values for discriminants, then build a subtype with those
+ -- defaults, and change the allocated subtype to that. Note
+ -- that this happens in fewer cases in Ada 2005 (AI95-0363).
+
+ if Nkind (N) = N_Allocator
+ and then not Is_Constrained (Full_Type)
+ and then
+ Present
+ (Discriminant_Default_Value (First_Discriminant (Full_Type)))
+ and then (Ada_Version < Ada_2005
+ or else not Object_Type_Has_Constrained_Partial_View
+ (Full_Type, Current_Scope))
+ then
+ Full_Type := Build_Default_Subtype (Full_Type, N);
+ Set_Expression (N, New_Occurrence_Of (Full_Type, Loc));
+ end if;
+
Discr := First_Discriminant (Full_Init_Type);
while Present (Discr) loop
if Is_CPP_Constructor_Call (Expression (Decl)) then
Actions :=
Build_Initialization_Call
- (Comp_Loc,
+ (Decl,
Id_Ref =>
Make_Selected_Component (Comp_Loc,
Prefix =>
Init_Call_Stmts :=
Build_Initialization_Call
- (Comp_Loc,
+ (Decl,
Make_Selected_Component (Comp_Loc,
Prefix =>
Make_Identifier (Comp_Loc, Name_uInit),
Append_List_To (Late_Stmts,
Build_Initialization_Call
- (Loc => Parent_Loc,
+ (N => Parent (Parent_Id),
Id_Ref =>
Make_Selected_Component (Parent_Loc,
Prefix => Make_Identifier
elsif Has_Non_Null_Base_Init_Proc (Typ) then
Append_List_To (Late_Stmts,
- Build_Initialization_Call (Comp_Loc,
+ Build_Initialization_Call (Decl,
Make_Selected_Component (Comp_Loc,
Prefix =>
Make_Identifier (Comp_Loc, Name_uInit),
Set_Assignment_OK (Id_Ref);
Insert_Actions_After (Init_After,
- Build_Initialization_Call (Loc, Id_Ref, Typ,
+ Build_Initialization_Call (N, Id_Ref, Typ,
Constructor_Ref => Expr));
-- We remove here the original call to the constructor
-- derived type; no new subprograms are constructed in this case.
function Build_Initialization_Call
- (Loc : Source_Ptr;
+ (N : Node_Id;
Id_Ref : Node_Id;
Typ : Entity_Id;
In_Init_Proc : Boolean := False;
-- Builds a call to the initialization procedure for the base type of Typ,
-- passing it the object denoted by Id_Ref, plus additional parameters as
-- appropriate for the type (the _Master, for task types, for example).
- -- Loc is the source location for the constructed tree. In_Init_Proc has
+ -- N is the construct for which the call is to be built. In_Init_Proc has
-- to be set to True when the call is itself in an init proc in order to
-- enable the use of discriminals.
--
Insert_Action (Allocator, Tmp_Obj);
Insert_List_After_And_Analyze (Tmp_Obj,
- Build_Initialization_Call (Loc,
+ Build_Initialization_Call (Allocator,
Id_Ref =>
Make_Explicit_Dereference (Loc,
Prefix => New_Occurrence_Of (Return_Obj_Access, Loc)),