-------------------------------
procedure Default_Initialize_Object (After : Node_Id) is
+ Exceptions_OK : constant Boolean :=
+ not Restriction_Active (No_Exception_Propagation);
+
function New_Object_Reference return Node_Id;
-- Return a new reference to Def_Id with attributes Assignment_OK and
-- Must_Not_Freeze already set.
(Init_Typ : Entity_Id) return Boolean
is
begin
- -- Do not consider the object declaration if it comes with an
- -- initialization expression, or is internal in which case it
- -- will be assigned later.
+ -- Skip internal entities as specified in Einfo
return
not Is_Internal (Def_Id)
- and then not Has_Init_Expression (N)
and then Needs_Simple_Initialization
(Typ => Init_Typ,
Consider_IS =>
-- Local variables
- Exceptions_OK : constant Boolean :=
- not Restriction_Active (No_Exception_Propagation);
-
Aggr_Init : Node_Id;
Comp_Init : List_Id := No_List;
Fin_Block : Node_Id;
-- Start of processing for Default_Initialize_Object
begin
+ -- Nothing to do if the object has an initialization expression or
+ -- need not be initialized.
+
+ if Has_Init_Expression (N) or else No_Initialization (N) then
+ return;
+
-- Default initialization is suppressed for objects that are already
-- known to be imported (i.e. whose declaration specifies the Import
-- aspect). Note that for objects with a pragma Import, we generate
-- the pragma. It is also suppressed for variables for which a pragma
-- Suppress_Initialization has been explicitly given
- if Is_Imported (Def_Id) or else Suppress_Initialization (Def_Id) then
+ elsif Is_Imported (Def_Id)
+ or else Suppress_Initialization (Def_Id)
+ then
return;
-- Nothing to do if the object being initialized is of a task type
-- Initialize the components of the object
if Has_Non_Null_Base_Init_Proc (Typ)
- and then not No_Initialization (N)
and then not Initialization_Suppressed (Typ)
then
-- Do not initialize the components if No_Default_Initialization
and then Simple_Initialization_OK (Component_Type (Typ))
then
- Set_No_Initialization (N, False);
Set_Expression (N,
Get_Simple_Init_Val
(Typ => Typ,
-- Provide a default value if the object needs simple initialization
elsif Simple_Initialization_OK (Typ) then
- Set_No_Initialization (N, False);
Set_Expression (N,
Get_Simple_Init_Val
(Typ => Typ,
-- Initialize the object, generate:
-- [Deep_]Initialize (Obj);
- if Needs_Finalization (Typ) and then not No_Initialization (N) then
+ if Needs_Finalization (Typ) then
Obj_Init :=
Make_Init_Call
(Obj_Ref => New_Object_Reference,