Commit 28be29ce by Ed Schonberg Committed by Arnaud Charlet

par-load.adb (Load): If a child unit is loaded through a limited_with clause...

2005-07-07  Ed Schonberg  <schonberg@adacore.com>
	    Javier Miranda  <miranda@adacore.com>

	* par-load.adb (Load): If a child unit is loaded through a limited_with
	clause, each parent must be loaded as a limited unit as well.

	* sem_ch10.adb (Previous_Withed_Unit): Better name for
	Check_Withed_Unit. Return true if there is a previous with_clause for
	this unit, whether limited or not.
	(Expand_Limited_With_Clause): Do not generate a limited_with_clause on
	the current unit.
	(Is_Visible_Through_Renamings): New local subprogram of install_limited
	_withed_unit that checks if some package installed through normal with
	clauses has a renaming declaration of package whose limited-view is
	ready to be installed. This enforces the check of the rule 10.1.2 (21/2)
	of the current Draft document for Ada 2005.
	(Analyze_Context): Complete the list of compilation units that
	are allowed to contain limited-with clauses. It also contains
	checks that were previously done by Install_Limited_Context_Clauses.
	This makes the code more clear and easy to maintain.
	(Expand_Limited_With_Clause) It is now a local subprogram of
	Install_Limited_Context_Clauses, and contains the code that adds
	the implicit limited-with clauses for parents of child units.
	This functionality was prevously done by Analyze_Context.

	* sem_ch4.adb (Analyze_Selected_Component): Check wrong use of
	incomplete type.

	* sem_ch7.adb (Analyze_Package_Declaration): Check if the package has
	been erroneously named in a limited-with clause of its own context.
	In this case the error has been previously notified by Analyze_Context.

From-SVN: r101697
parent 4e7ce6ab
......@@ -301,6 +301,8 @@ begin
end if;
-- If current unit is a child unit spec, load its parent
-- If the child unit is loaded through a limited with, the parent
-- must be as well.
elsif Nkind (Unit (Curunit)) = N_Package_Declaration
or else Nkind (Unit (Curunit)) = N_Subprogram_Declaration
......@@ -323,7 +325,8 @@ begin
(Load_Name => Spec_Name,
Required => True,
Subunit => False,
Error_Node => Curunit);
Error_Node => Curunit,
From_Limited_With => From_Limited_With);
if Unum /= No_Unit then
Set_Parent_Spec (Unit (Curunit), Cunit (Unum));
......
......@@ -2679,6 +2679,25 @@ package body Sem_Ch4 is
Resolve (Name);
-- Ada 2005 (AI-50217): Check wrong use of incomplete type.
-- Example:
-- limited with Pkg;
-- package Pkg is
-- type Acc_Inc is access Pkg.T;
-- X : Acc_Inc;
-- N : Natural := X.all.Comp; -- ERROR
-- end Pkg;
if Nkind (Name) = N_Explicit_Dereference
and then From_With_Type (Etype (Prefix (Name)))
and then not Is_Potentially_Use_Visible (Etype (Name))
then
Error_Msg_NE
("premature usage of incomplete}", Prefix (Name),
Etype (Prefix (Name)));
end if;
-- We never need an actual subtype for the case of a selection
-- for a indexed component of a non-packed array, since in
-- this case gigi generates all the checks and can find the
......
......@@ -623,6 +623,17 @@ package body Sem_Ch7 is
PF : Boolean;
begin
-- Ada 2005 (AI-217): Check if the package has been erroneously named
-- in a limited-with clause of its own context. In this case the error
-- has been previously notified by Analyze_Context.
-- limited with Pkg; -- ERROR
-- package Pkg is ...
if From_With_Type (Id) then
return;
end if;
Generate_Definition (Id);
Enter_Name (Id);
Set_Ekind (Id, E_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