Commit 31b5873d by Gary Dismukes Committed by Arnaud Charlet

freeze.adb (Freeze_Entity): Remove check for preelaborable initialization of a full view.

2007-09-26  Gary Dismukes  <dismukes@adacore.com>

	* freeze.adb (Freeze_Entity): Remove check for preelaborable
	initialization of a full view. This is moved to
	Analyze_Package_Specification.

	* sem_ch7.adb (Analyze_Package_Specification): Add check for
	preelaborable initialization of a full view in entity loop.
	(Uninstall_Declarations): If entity is a use-visible compilation unit,
	its child units are use-visible only if they are visible child units.

	* sem_util.adb (Is_Preelaborable_Expression): New function to determine
	whether an expression can be used within a type declaration that
	requires preelaborable init.
	(Check_Components): Replace inline code that does partial checking for
	preelaborable default expressions with call to
	Is_Preelaborable_Expression.
	(Has_Preelaborable_Initialization): In the case of a generic actual
	subtype, (that is, Is_Generic_Actual is True), return the result of
	applying Has_Preelaborable_Initialization to the generic actual's base
	type.

From-SVN: r128789
parent af04dc07
......@@ -2542,15 +2542,13 @@ package body Freeze is
-- Case of a type or subtype being frozen
else
-- Check preelaborable initialization for full type completing a
-- private type for which pragma Preelaborable_Initialization given.
if Must_Have_Preelab_Init (E)
and then not Has_Preelaborable_Initialization (E)
then
Error_Msg_N
("full view of & does not have preelaborable initialization", E);
end if;
-- We used to check here that a full type must have preelaborable
-- initialization if it completes a private type specified with
-- pragma Preelaborable_Intialization, but that missed cases where
-- the types occur within a generic package, since the freezing
-- that occurs within a containing scope generally skips traversal
-- of a generic unit's declarations (those will be frozen within
-- instances). This check was moved to Analyze_Package_Specification.
-- The type may be defined in a generic unit. This can occur when
-- freezing a generic function that returns the type (which is
......
......@@ -1168,15 +1168,27 @@ package body Sem_Ch7 is
Set_First_Private_Entity (Id, Next_Entity (L));
end if;
-- Check rule of 3.6(11), which in general requires waiting till all
-- full types have been seen.
E := First_Entity (Id);
while Present (E) loop
-- Check rule of 3.6(11), which in general requires waiting till all
-- full types have been seen.
if Ekind (E) = E_Record_Type or else Ekind (E) = E_Array_Type then
Check_Aliased_Component_Types (E);
end if;
-- Check preelaborable initialization for full type completing a
-- private type for which pragma Preelaborable_Initialization given.
if Is_Type (E)
and then Must_Have_Preelab_Init (E)
and then not Has_Preelaborable_Initialization (E)
then
Error_Msg_N
("full view of & does not have preelaborable initialization", E);
end if;
Next_Entity (E);
end loop;
......@@ -2024,8 +2036,24 @@ package body Sem_Ch7 is
Type_In_Use
(Etype (Next_Formal (First_Formal (Id))))));
else
Set_Is_Potentially_Use_Visible (Id,
In_Use (P) and not Is_Hidden (Id));
if In_Use (P) and then not Is_Hidden (Id) then
-- A child unit of a use-visible package remains use-visible
-- only if it is itself a visible child unit. Otherwise it
-- would remain visible in other contexts where P is use-
-- visible, because once compiled it stays in the entity list
-- of its parent unit.
if Is_Child_Unit (Id) then
Set_Is_Potentially_Use_Visible (Id,
Is_Visible_Child_Unit (Id));
else
Set_Is_Potentially_Use_Visible (Id);
end if;
else
Set_Is_Potentially_Use_Visible (Id, False);
end if;
end if;
-- Local entities are not immediately visible outside of the package
......
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