diff mbox

[Ada] Conformance checks on partially parametrized formal packages

Message ID 20111121112623.GA9600@adacore.com
State New
Headers show

Commit Message

Arnaud Charlet Nov. 21, 2011, 11:26 a.m. UTC
A formal subprogram of the formal package can be specified with a box default,
or can be covered by an others association with a box initialization. In either
case there is no need to check its conformance with the actual subprogram that
appears in the instantiation of the formal package. This patch covers the case
of an others association, whose representation is different from that of an
explicit box initialization for the formal subprogram.

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

2011-11-21  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch12.adb (Check_Formal_Package_Instance): If a formal
	subprogram of the formal package is covered by an others
	association with a box initialization, no check is needed
	against the actual in the instantiation of the formal package.
diff mbox

Patch

Index: sem_ch12.adb
===================================================================
--- sem_ch12.adb	(revision 181556)
+++ sem_ch12.adb	(working copy)
@@ -5076,6 +5076,18 @@ 
             then
                null;
 
+            --  If the formal package has an "others"  box association that
+            --  covers this formal, there is no need for a check either.
+
+            elsif Nkind (Unit_Declaration_Node (E2)) in
+                    N_Formal_Subprogram_Declaration
+              and then Box_Present (Unit_Declaration_Node (E2))
+            then
+               null;
+
+            --  Otherwise the actual in the formal and the actual in the
+            --  instantiation of the formal must match, up to renamings.
+
             else
                Check_Mismatch
                  (Ekind (E2) /= Ekind (E1) or else (Alias (E1)) /= Alias (E2));
@@ -12383,9 +12395,11 @@ 
       procedure Reset_Entity (N : Node_Id) is
 
          procedure Set_Global_Type (N : Node_Id; N2 : Node_Id);
-         --  If the type of N2 is global to the generic unit. Save the type in
-         --  the generic node.
-         --  What does this comment mean???
+         --  If the type of N2 is global to the generic unit, save the type in
+         --  the generic node. Just as we perform name capture for explicit
+         --  references within the generic, we must capture the global types
+         --  of local entities because they may participate in resolution in
+         --  the instance.
 
          function Top_Ancestor (E : Entity_Id) return Entity_Id;
          --  Find the ultimate ancestor of the current unit. If it is not a