[Ada] Itype references for anonymous access return types

Arnaud Charlet charlet@adacore.com
Mon Aug 17 09:42:00 GMT 2009


The anonymous access types created for return types must be elaborated in the
calling context of the function.  We force this elaboration by generating an
itype reference for the anonymous access. If the function is generic, this
type cannot be elaborated, given that the backend does not process generic
units at all.  Therefore the itype reference must not be generated if the
designated type is a generic formal type.

See gnat.dg/itype.ad[sb]

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

2009-08-17  Ed Schonberg  <schonberg@adacore.com>

	* sem_ch3.adb (Access_Definition): Do not create an Itype reference for
	an anonymous access type whose designated type is generic.

-------------- next part --------------
Index: sem_ch3.adb
===================================================================
--- sem_ch3.adb	(revision 150823)
+++ sem_ch3.adb	(working copy)
@@ -939,9 +939,12 @@ package body Sem_Ch3 is
       --  type declaration. In either case, do not create a reference for a
       --  type obtained through a limited_with clause, because this would
       --  introduce semantic dependencies.
+      --  Similarly, do not create a reference if the designated type is a
+      --  generic formal, because no use of it will reach the backend.
 
       elsif Nkind (Related_Nod) = N_Function_Specification
         and then not From_With_Type (Desig_Type)
+        and then not Is_Generic_Type (Desig_Type)
       then
          if Present (Enclosing_Prot_Type) then
             Build_Itype_Reference (Anon_Type, Parent (Enclosing_Prot_Type));


More information about the Gcc-patches mailing list