[Ada] Decoration of limited-with clauses

Arnaud Charlet charlet@adacore.com
Wed Dec 5 10:13:00 GMT 2012


Building the limited view of a package does not perform a semantic analysis of
the package.  Nevertheless the limited-with clause must carry the entity of the
unit, so that warnings on unused with_clauses can be properly supported.

No short reproducer available.

Tested on x86_64-pc-linux-gnu, committed on trunk

2012-12-05  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch10.adb (Build_Limited_Views): Even though the unit is
	not analyzed, place its entity on the name in the with clause,
	so that warnings on unused with-clause are properly supported
	for limited withs.

-------------- next part --------------
Index: sem_ch10.adb
===================================================================
--- sem_ch10.adb	(revision 194188)
+++ sem_ch10.adb	(working copy)
@@ -5716,6 +5716,17 @@
             raise Program_Error;
       end case;
 
+      --  The limited unit is not analyzed but the with clause must be
+      --  minimally decorated so that checks on unused with clause also work
+      --  with limited with clauses.
+
+      if Is_Entity_Name (Name (N)) then
+         Set_Entity (Name (N), P);
+
+      elsif Nkind (Name (N)) = N_Selected_Component then
+         Set_Entity (Selector_Name (Name (N)), P);
+      end if;
+
       --  Check if the chain is already built
 
       Spec := Specification (Unit (Library_Unit (N)));
Index: sem_ch3.adb
===================================================================
--- sem_ch3.adb	(revision 194190)
+++ sem_ch3.adb	(working copy)
@@ -6512,23 +6512,27 @@
       then
          Append_Elmt (Derived_Type, Private_Dependents (Parent_Type));
 
+         --  Check for unusual case where a type completed by a private
+         --  derivation occurs within a package nested in a child unit, and
+         --  the parent is declared in an ancestor.
+
          if Is_Child_Unit (Scope (Current_Scope))
            and then Is_Completion
            and then In_Private_Part (Current_Scope)
            and then Scope (Parent_Type) /= Current_Scope
+
+           --  Note that if the parent has a completion in the private part,
+           --  (which is itself a derivation from some other private type)
+           --  it is that completion that is visible, there is no full view
+           --  available, and no special processing is needed.
+
            and then Present (Full_View (Parent_Type))
          then
-            --  This is the unusual case where a type completed by a private
-            --  derivation occurs within a package nested in a child unit, and
-            --  the parent is declared in an ancestor. In this case, the full
-            --  view of the parent type will become visible in the body of
-            --  the enclosing child, and only then will the current type be
-            --  possibly non-private. We build a underlying full view that
-            --  will be installed when the enclosing child body is compiled.
-            --  Note that if the parent has a completion in the private part,
-            --  (which is itself a derivation from some other private type)
-            --  it is that completion that is visible, there is no full view
-            --  view available, and no special processing is needed.
+            --  In this case, the full view of the parent type will become
+            --  visible in the body of the enclosing child, and only then will
+            --  the current type be possibly non-private. We build an
+            --  underlying full view that will be installed when the enclosing
+            --  child body is compiled.
 
             Full_Der :=
               Make_Defining_Identifier


More information about the Gcc-patches mailing list