Typ => Ctype,
With_Default_Init => True));
- -- If Default_Initial_Condition applies to the component type,
- -- add a DIC check after the component is default-initialized.
- -- It will be analyzed and resolved before the code for
- -- initialization of other components.
-
- -- Theoretically this might also be needed for cases where
- -- the component type doesn't have an init proc (such as for
- -- Default_Value cases), but those should be uncommon, and for
- -- now we only support the init proc case. ???
-
- if Has_DIC (Ctype) and then Present (DIC_Procedure (Ctype)) then
- Append_To (Stmts,
- Build_DIC_Call (Loc, New_Copy_Tree (Indexed_Comp), Ctype));
- end if;
-
-- If the component type has invariants, add an invariant
-- check after the component is default-initialized. It will
-- be analyzed and resolved before the code for initialization
Append_To (Stmts, Init_Call);
end if;
end if;
+
+ -- If Default_Initial_Condition applies to the component type,
+ -- add a DIC check after the component is default-initialized,
+ -- as well as after an Initialize procedure is called, in the
+ -- case of components of a controlled type. It will be analyzed
+ -- and resolved before the code for initialization of other
+ -- components.
+
+ -- Theoretically this might also be needed for cases where Expr
+ -- is not empty, but a default init still applies, such as for
+ -- Default_Value cases, in which case we won't get here. ???
+
+ if Has_DIC (Ctype) and then Present (DIC_Procedure (Ctype)) then
+ Append_To (Stmts,
+ Build_DIC_Call (Loc, New_Copy_Tree (Indexed_Comp), Ctype));
+ end if;
end if;
return Add_Loop_Actions (Stmts);
and then not GNATprove_Mode
+ -- DIC checks for components of controlled types are done later
+ -- (see Exp_Ch7.Make_Deep_Array_Body).
+
+ and then not Is_Controlled (Comp_Type)
+
and then Present (DIC_Procedure (Comp_Type))
and then not Has_Null_Body (DIC_Procedure (Comp_Type))
Init_Call := Build_Initialization_Call;
- -- Only create finalization block if there is a non-trivial
- -- call to initialization.
-
- if Present (Init_Call)
- and then Nkind (Init_Call) /= N_Null_Statement
+ -- Only create finalization block if there is a nontrivial call
+ -- to initialization or a Default_Initial_Condition check to be
+ -- performed.
+
+ if (Present (Init_Call)
+ and then Nkind (Init_Call) /= N_Null_Statement)
+ or else
+ (Has_DIC (Comp_Typ)
+ and then not GNATprove_Mode
+ and then Present (DIC_Procedure (Comp_Typ))
+ and then not Has_Null_Body (DIC_Procedure (Comp_Typ)))
then
- Init_Loop :=
- Make_Block_Statement (Loc,
- Handled_Statement_Sequence =>
- Make_Handled_Sequence_Of_Statements (Loc,
- Statements => New_List (Init_Call),
- Exception_Handlers => New_List (
- Make_Exception_Handler (Loc,
- Exception_Choices => New_List (
- Make_Others_Choice (Loc)),
- Statements => New_List (Final_Block)))));
+ declare
+ Init_Stmts : constant List_Id := New_List;
+
+ begin
+ if Present (Init_Call) then
+ Append_To (Init_Stmts, Init_Call);
+ end if;
+
+ if Has_DIC (Comp_Typ)
+ and then Present (DIC_Procedure (Comp_Typ))
+ then
+ Append_To
+ (Init_Stmts,
+ Build_DIC_Call (Loc,
+ Make_Indexed_Component (Loc,
+ Prefix => Make_Identifier (Loc, Name_V),
+ Expressions => New_References_To (Index_List, Loc)),
+ Comp_Typ));
+ end if;
+
+ Init_Loop :=
+ Make_Block_Statement (Loc,
+ Handled_Statement_Sequence =>
+ Make_Handled_Sequence_Of_Statements (Loc,
+ Statements => Init_Stmts,
+ Exception_Handlers => New_List (
+ Make_Exception_Handler (Loc,
+ Exception_Choices => New_List (
+ Make_Others_Choice (Loc)),
+ Statements => New_List (Final_Block)))));
+ end;
Append_To (Statements (Handled_Statement_Sequence (Init_Loop)),
Make_Assignment_Statement (Loc,
-- by default, then set flag on the new association to indicate that
-- the original association was for such a box-initialized component.
- if Resolve_Record_Aggregate.Is_Box_Present
- and then not Is_Box_Present
- and then Is_Box_Init_By_Default -- ???
- then
+ if Is_Box_Init_By_Default then
Set_Was_Default_Init_Box_Association (Last (Assoc_List));
end if;
end Add_Association;
-- Default_Initial_Condition
elsif Is_Default_Initial_Condition_Proc (Subp_Id) then
- Output_Verification_Call
- (Pred => "Default_Initial_Condition",
- Id => First_Formal_Type (Subp_Id),
- Id_Kind => "type");
+
+ -- Only do output for a normal DIC procedure, since partial DIC
+ -- procedures are subsidiary to those.
+
+ if not Is_Partial_DIC_Procedure (Subp_Id) then
+ Output_Verification_Call
+ (Pred => "Default_Initial_Condition",
+ Id => First_Formal_Type (Subp_Id),
+ Id_Kind => "type");
+ end if;
-- Entries