[Ada] yet another fix in handling of limited-with

Arnaud Charlet charlet@adacore.com
Mon Jul 4 13:52:00 GMT 2005


Tested on i686-linux, committed on mainline.

In an context where both the limited and non-limited views of a package
are available, two references to the same type may correspond to its
non-limited and limited view. When checking conformance, always use the
non-limited view if available.
The following must compile without errors:
gcc -c -gnat05 -gnatc d.ads

package B is
   type B_Type is new Integer;
end;

limited with B;
package C is
   type C_Type is abstract tagged null record;
   procedure P (
     A_C : C_Type;
     A_B : access B.B_Type)
   is abstract;
end;

with B;
with C;
package D is
   type D_Type is new C.C_Type with null record;
   procedure P (
     A_D : D_Type;
     A_B : access B.B_Type);
end;

2005-07-04  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch6.adb (Conforming_Types): If the types are anonymous access
	types check whether some designated type is a limited view, and use
	the non-limited view if available.

-------------- next part --------------
Index: sem_ch6.adb
===================================================================
RCS file: /cvs/gcc/gcc/gcc/ada/sem_ch6.adb,v
retrieving revision 1.34
diff -u -p -r1.34 sem_ch6.adb
--- sem_ch6.adb	1 Jul 2005 01:28:04 -0000	1.34
+++ sem_ch6.adb	4 Jul 2005 13:19:35 -0000
@@ -3326,19 +3326,27 @@ package body Sem_Ch6 is
             Desig_1 := Directly_Designated_Type (Type_1);
 
             --  An access parameter can designate an incomplete type
+            --  If the incomplete type is the limited view of a type
+            --  from a limited_with_clause, check whether the non-limited
+            --  view is available.
+
+            if Ekind (Desig_1) = E_Incomplete_Type then
+               if Present (Full_View (Desig_1)) then
+                  Desig_1 := Full_View (Desig_1);
 
-            if Ekind (Desig_1) = E_Incomplete_Type
-              and then Present (Full_View (Desig_1))
-            then
-               Desig_1 := Full_View (Desig_1);
+               elsif Present (Non_Limited_View (Desig_1)) then
+                  Desig_1 := Non_Limited_View (Desig_1);
+               end if;
             end if;
 
             Desig_2 := Directly_Designated_Type (Type_2);
 
-            if Ekind (Desig_2) = E_Incomplete_Type
-              and then Present (Full_View (Desig_2))
-            then
-               Desig_2 := Full_View (Desig_2);
+            if Ekind (Desig_2) = E_Incomplete_Type then
+               if Present (Full_View (Desig_2)) then
+                  Desig_2 := Full_View (Desig_2);
+               elsif Present (Non_Limited_View (Desig_2)) then
+                  Desig_2 := Non_Limited_View (Desig_2);
+               end if;
             end if;
 
             --  The context is an instance association for a formal


More information about the Gcc-patches mailing list