Commit 26a29f01 by Gary Dismukes Committed by Arnaud Charlet

exp_ch3.adb (Build_Array_Init_Proc): Clarify comment related to creating dummy init proc.

2008-08-20  Gary Dismukes  <dismukes@adacore.com>

	* exp_ch3.adb (Build_Array_Init_Proc): Clarify comment related to
	creating dummy init proc.
	(Requires_Init_Proc): Return False in the case No_Default_Initialization
	is in force and the type does not have associated default
	initialization. Move test of Is_Public (with tests of restrictions
	No_Initialize_Scalars and No_Default_Initialization) to end, past tests
	for default initialization.

From-SVN: r139313
parent aa2fca8f
......@@ -692,9 +692,9 @@ package body Exp_Ch3 is
-- would be needed if this restriction was not active (so that we can
-- detect attempts to call it), so set a dummy init_proc in place.
-- This is only done though when actual default initialization is
-- needed, so we exclude the setting in the Is_Public case, such
-- as for arrays of scalars, since otherwise such objects would be
-- wrongly flagged as violating the restriction.
-- needed (and not done when only Is_Public is True), since otherwise
-- objects such as arrays of scalars could be wrongly flagged as
-- violating the restriction.
if Restriction_Active (No_Default_Initialization) then
if Has_Default_Init then
......@@ -3013,11 +3013,6 @@ package body Exp_Ch3 is
elsif Is_Interface (Rec_Id) then
return False;
elsif not Restriction_Active (No_Initialize_Scalars)
and then Is_Public (Rec_Id)
then
return True;
elsif (Has_Discriminants (Rec_Id)
and then not Is_Unchecked_Union (Rec_Id))
or else Is_Tagged_Type (Rec_Id)
......@@ -3042,6 +3037,22 @@ package body Exp_Ch3 is
Next_Component (Id);
end loop;
-- As explained above, a record initialization procedure is needed
-- for public types in case Initialize_Scalars applies to a client.
-- However, such a procedure is not needed in the case where either
-- of restrictions No_Initialize_Scalars or No_Default_Initialization
-- apply. No_Initialize_Scalars excludes the possibility of using
-- Initialize_Scalars in any partition, and No_Default_Initialization
-- implies that no initialization should ever be done for objects of
-- the type, so is incompatible with Initialize_Scalars.
if not Restriction_Active (No_Initialize_Scalars)
and then not Restriction_Active (No_Default_Initialization)
and then Is_Public (Rec_Id)
then
return True;
end if;
return False;
end Requires_Init_Proc;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment