-- To support this feature, the analysis of a limited_with clause must
-- create an abbreviated view of the package, without performing any
- -- semantic analysis on it. This "package abstract" contains shadow
- -- types that are in one-one correspondence with the real types in the
- -- package, and that have the properties of incomplete types.
+ -- semantic analysis on it. This "package abstract" contains shadow types
+ -- that are in one-one correspondence with the real types in the package,
+ -- and that have the properties of incomplete types.
-- The implementation creates two element lists: one to chain the shadow
-- entities, and one to chain the corresponding type entities in the tree
Use_Item : Node_Id;
function Same_Unit (N : Node_Id; P : Entity_Id) return Boolean;
- -- In an expanded name in a use clause, if the prefix is a
- -- renamed package, the entity is set to the original package
- -- as a result, when checking whether the package appears in a
- -- previous with_clause, the renaming has to be taken into
- -- account, to prevent spurious or incorrect warnings. The
- -- common case is the use of Text_IO.
+ -- In an expanded name in a use clause, if the prefix is a renamed
+ -- package, the entity is set to the original package as a result,
+ -- when checking whether the package appears in a previous with
+ -- clause, the renaming has to be taken into account, to prevent
+ -- spurious/incorrect warnings. A common case is use of Text_IO.
---------------
-- Same_Unit --
Cont_Item := First (Context_List);
while Present (Cont_Item) loop
- -- Stop the search since the context items after Cont_Item
- -- have already been examined in a previous iteration of
- -- the reverse loop in Check_Redundant_Withs.
+ -- Stop the search since the context items after Cont_Item have
+ -- already been examined in a previous iteration of the reverse
+ -- loop in Check_Redundant_Withs.
if Exit_On_Self
and Cont_Item = Clause
end loop;
-- Package with clause. Avoid processing self, implicitly
- -- generated with clauses or limited with clauses. Note
- -- that we examine with clauses having pragmas Elaborate
- -- or Elaborate_All applied to them due to cases such as:
+ -- generated with clauses or limited with clauses. Note that
+ -- we examine with clauses having pragmas Elaborate or
+ -- Elaborate_All applied to them due to cases such as:
--
+
-- with Pack;
-- with Pack;
-- pragma Elaborate (Pack);
Clause := Last (Context_Items);
while Present (Clause) loop
- -- Avoid checking implicitly generated with clauses, limited
- -- with clauses or withs that have pragma Elaborate or
- -- Elaborate_All applied.
+ -- Avoid checking implicitly generated with clauses, limited with
+ -- clauses or withs that have pragma Elaborate or Elaborate_All.
if Nkind (Clause) = N_With_Clause
and then not Implicit_With (Clause)
-- analysis of the parent, which we proceed to do. Basically this gets
-- handled from the top down and we don't want to do anything at this
-- level (i.e. this subunit will be handled on the way down from the
- -- parent), so at this level we immediately return. If the subunit
- -- ends up not analyzed, it means that the parent did not contain a
- -- stub for it, or that there errors were detected in some ancestor.
+ -- parent), so at this level we immediately return. If the subunit ends
+ -- up not analyzed, it means that the parent did not contain a stub for
+ -- it, or that there errors were detected in some ancestor.
if Nkind (Unit_Node) = N_Subunit
and then not Analyzed (Lib_Unit)
return;
end if;
- -- Analyze context (this will call Sem recursively for with'ed units)
- -- To detect circularities among with-clauses that are not caught during
+ -- Analyze context (this will call Sem recursively for with'ed units) To
+ -- detect circularities among with-clauses that are not caught during
-- loading, we set the Context_Pending flag on the current unit. If the
- -- flag is already set there is a potential circularity.
- -- We exclude predefined units from this check because they are known
- -- to be safe. We also exclude package bodies that are present because
- -- circularities between bodies are harmless (and necessary).
+ -- flag is already set there is a potential circularity. We exclude
+ -- predefined units from this check because they are known to be safe.
+ -- We also exclude package bodies that are present because circularities
+ -- between bodies are harmless (and necessary).
if Context_Pending (N) then
declare
end if;
end if;
- -- Remove unit from visibility, so that environment is clean for
- -- the next compilation, which is either the main unit or some
- -- other unit in the context.
+ -- Remove unit from visibility, so that environment is clean for the
+ -- next compilation, which is either the main unit or some other unit
+ -- in the context.
if Nkind_In (Unit_Node, N_Package_Declaration,
N_Package_Renaming_Declaration,
Remove_Unit_From_Visibility (Defining_Entity (Unit_Node));
-- If the unit is an instantiation whose body will be elaborated for
- -- inlining purposes, use the proper entity of the instance. The
- -- entity may be missing if the instantiation was illegal.
+ -- inlining purposes, use the proper entity of the instance. The entity
+ -- may be missing if the instantiation was illegal.
elsif Nkind (Unit_Node) = N_Package_Instantiation
and then not Error_Posted (Unit_Node)
Comp_Unit : Node_Id;
begin
- -- Try to load subunit, but ignore any errors that occur during
- -- the loading of the subunit, by using the special feature in
- -- Errout to ignore all errors. Note that Fatal_Error will still
- -- be set, so we will be able to check for this case below.
+ -- Try to load subunit, but ignore any errors that occur during the
+ -- loading of the subunit, by using the special feature in Errout to
+ -- ignore all errors. Note that Fatal_Error will still be set, so we
+ -- will be able to check for this case below.
if not ASIS_Mode then
Ignore_Errors_Enable := Ignore_Errors_Enable + 1;
return;
-- If the subunit is not already loaded, and we are generating code,
- -- then this is the case where compilation started from the parent,
- -- and we are generating code for an entire subunit tree. In that
- -- case we definitely need to load the subunit.
+ -- then this is the case where compilation started from the parent, and
+ -- we are generating code for an entire subunit tree. In that case we
+ -- definitely need to load the subunit.
-- In order to continue the analysis with the rest of the parent,
-- and other subunits, we load the unit without requiring its
elsif Original_Operating_Mode = Generate_Code then
- -- If the proper body is already linked to the stub node,
- -- the stub is in a generic unit and just needs analyzing.
+ -- If the proper body is already linked to the stub node, the stub is
+ -- in a generic unit and just needs analyzing.
- -- We update the version. Although we are not technically
- -- semantically dependent on the subunit, given our approach
- -- of macro substitution of subunits, it makes sense to
- -- include it in the version identification.
+ -- We update the version. Although we are not strictly technically
+ -- semantically dependent on the subunit, given our approach of macro
+ -- substitution of subunits, it makes sense to include it in the
+ -- version identification.
if Present (Library_Unit (N)) then
Set_Corresponding_Stub (Unit (Library_Unit (N)), N);
Subunit => True,
Error_Node => N);
- -- Give message if we did not get the unit
- -- Emit warning even if missing subunit is not
- -- within main unit, to simplify debugging.
+ -- Give message if we did not get the unit Emit warning even if
+ -- missing subunit is not within main unit, to simplify debugging.
if Original_Operating_Mode = Generate_Code
and then Unum = No_Unit
end if;
-- Load_Unit may reset Compiler_State, since it may have been
- -- necessary to parse an additional units, so we make sure
- -- that we reset it to the Analyzing state.
+ -- necessary to parse an additional units, so we make sure that
+ -- we reset it to the Analyzing state.
Compiler_State := Analyzing;
Sub_Parent := Library_Unit (N);
Curr_Unit := Defining_Entity (Unit (Library_Unit (Sub_Parent)));
- -- If the parent itself is a subunit, Curr_Unit is the entity
- -- of the enclosing body, retrieve the spec entity which is
- -- the proper ancestor we need for the following tests.
+ -- If the parent itself is a subunit, Curr_Unit is the entity of the
+ -- enclosing body, retrieve the spec entity which is the proper
+ -- ancestor we need for the following tests.
if Ekind (Curr_Unit) = E_Package_Body then
Curr_Unit := Spec_Entity (Curr_Unit);
begin
if Nkind (Nam) = N_Identifier then
- -- If the parent unit P in the name of the with_clause for P.Q
- -- is a renaming of package R, then the entity of the parent is
- -- set to R, but the identifier retains Chars (P) to be consistent
- -- with the source (see details in lib-load). However, the
- -- implicit_with_clause for the parent must make the entity for
- -- P visible, because P.Q may be used as a prefix within the
- -- current unit. The entity for P is the current_entity with that
- -- name, because the package renaming declaration for it has just
- -- been analyzed. Note that this case can only happen if P.Q has
- -- already appeared in a previous with_clause in a related unit,
- -- such as the library body of the current unit.
+ -- If the parent unit P in the name of the with_clause for P.Q is
+ -- a renaming of package R, then the entity of the parent is set
+ -- to R, but the identifier retains Chars (P) to be consistent
+ -- with the source (see details in lib-load). However the implicit
+ -- with_clause for the parent must make the entity for P visible,
+ -- because P.Q may be used as a prefix within the current unit.
+ -- The entity for P is the current_entity with that name, because
+ -- the package renaming declaration for it has just been analyzed.
+ -- Note that this case can only happen if P.Q has already appeared
+ -- in a previous with_clause in a related unit, such as the
+ -- library body of the current unit.
if Chars (Nam) /= Chars (Entity (Nam)) then
Renaming := Current_Entity (Nam);
Nkind (Unit_Declaration_Node (Entity (Selector_Name (Nam))))
= N_Package_Renaming_Declaration
then
- -- The name in the with_clause is of the form A.B.C, and B
- -- is given by a renaming declaration. In that case we may
- -- not have analyzed the unit for B, but replaced it directly
- -- in lib-load with the unit it renames. We have to make A.B
+ -- The name in the with_clause is of the form A.B.C, and B is
+ -- given by a renaming declaration. In that case we may not
+ -- have analyzed the unit for B, but replaced it directly in
+ -- lib-load with the unit it renames. We have to make A.B
-- visible, so analyze the declaration for B now, in case it
-- has not been done yet.
Subunit => False,
Error_Node => Nam);
- -- Do not generate a limited_with_clause on the current unit.
- -- This path is taken when a unit has a limited_with clause on
- -- one of its child units.
+ -- Do not generate a limited_with_clause on the current unit. This
+ -- path is taken when a unit has a limited_with clause on one of its
+ -- child units.
if Unum = Current_Sem_Unit then
return;
Next (Item);
end loop;
- -- Ada 2005 (AI-412): Examine the visible declarations of a package
- -- spec, looking for incomplete subtype declarations of incomplete types
+ -- Ada 2005 (AI-412): Examine visible declarations of a package spec,
+ -- looking for incomplete subtype declarations of incomplete types
-- visible through a limited with clause.
if Ada_Version >= Ada_05
-- Convert an incomplete subtype declaration into a
-- corresponding non-limited view subtype declaration.
-- This is usually the case when analyzing a body that
- -- has regular with-clauses, when the spec has limited
+ -- has regular with clauses, when the spec has limited
-- ones.
-- If the non-limited view is still incomplete, it is
end loop;
end;
- -- Finally, check whether there are subprograms that still
- -- require a body, i.e. are not renamings or null.
+ -- Finally, check whether there are subprograms that still require
+ -- a body, i.e. are not renamings or null.
if not Is_Empty_Elmt_List (Subp_List) then
declare
return True;
end if;
- -- If there are more ancestors, climb up the tree, otherwise
- -- we are done.
+ -- If there are more ancestors, climb up the tree, otherwise we
+ -- are done.
if Is_Child_Unit (Par) then
Par := Scope (Par);
-- Do not install the limited view if this is the unit being analyzed.
-- This unusual case will happen when a unit has a limited_with clause
- -- on one of its children. The compilation of the child forces the
- -- load of the parent which tries to install the limited view of the
- -- child again. Installing the limited view must also be disabled
- -- when compiling the body of the child unit.
+ -- on one of its children. The compilation of the child forces the load
+ -- of the parent which tries to install the limited view of the child
+ -- again. Installing the limited view must also be disabled when
+ -- compiling the body of the child unit.
if P = Cunit_Entity (Current_Sem_Unit)
or else
return;
end if;
- -- This scenario is similar to the one above, the difference is that
- -- the compilation of sibling Par.Sib forces the load of parent Par
- -- which tries to install the limited view of Lim_Pack [1]. However
- -- Par.Sib has a with clause for Lim_Pack [2] in its body, and thus
- -- needs the non-limited views of all entities from Lim_Pack.
+ -- This scenario is similar to the one above, the difference is that the
+ -- compilation of sibling Par.Sib forces the load of parent Par which
+ -- tries to install the limited view of Lim_Pack [1]. However Par.Sib
+ -- has a with clause for Lim_Pack [2] in its body, and thus needs the
+ -- non-limited views of all entities from Lim_Pack.
-- limited with Lim_Pack; -- [1]
-- package Par is ... package Lim_Pack is ...
return;
end if;
- -- A common use of the limited-with is to have a limited-with
- -- in the package spec, and a normal with in its package body.
- -- For example:
+ -- A common use of the limited-with is to have a limited-with in the
+ -- package spec, and a normal with in its package body. For example:
-- limited with X; -- [1]
-- package A is ...
Prev := Current_Entity (Lim_Typ);
E := Prev;
- -- Replace E in the homonyms list, so that the limited
- -- view becomes available.
+ -- Replace E in the homonyms list, so that the limited view
+ -- becomes available.
if E = Non_Limited_View (Lim_Typ) then
Set_Homonym (Lim_Typ, Homonym (Prev));
loop
E := Homonym (Prev);
- -- E may have been removed when installing a
- -- previous limited_with_clause.
+ -- E may have been removed when installing a previous
+ -- limited_with_clause.
exit when No (E);
Check_Body_Required;
end if;
- -- If the package in the limited_with clause is a child unit, the
- -- clause is unanalyzed and appears as a selected component. Recast
- -- it as an expanded name so that the entity can be properly set. Use
- -- entity of parent, if available, for higher ancestors in the name.
+ -- If the package in the limited_with clause is a child unit, the clause
+ -- is unanalyzed and appears as a selected component. Recast it as an
+ -- expanded name so that the entity can be properly set. Use entity of
+ -- parent, if available, for higher ancestors in the name.
if Nkind (Name (N)) = N_Selected_Component then
declare
Write_Eol;
end if;
- -- Prepare the removal of the shadow entities from visibility. The
- -- first element of the limited view is a header (an E_Package
- -- entity) that is used to reference the first shadow entity in the
- -- private part of the package
+ -- Prepare the removal of the shadow entities from visibility. The first
+ -- element of the limited view is a header (an E_Package entity) that is
+ -- used to reference the first shadow entity in the private part of the
+ -- package
Lim_Header := Limited_View (P);
Lim_Typ := First_Entity (Lim_Header);