[Ada] Implicit dereference when type is an access_to_subprogram.

Arnaud Charlet charlet@adacore.com
Wed Aug 6 09:44:00 GMT 2008


If the return type of the function is an access_to_subprogram and the context
type is not, this is a parameterless call that is the prefix of the actual
call. In an instance, the return type may appear simply as an access_subtype
if it is an actual, and the base type must be used to recognize this case.

See gnat.dg/test_call.adb

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

2008-08-06  Ed Schonberg  <schonberg@adacore.com>

	* sem_res.adb (Resolve_Call): Use base type to determine whether a
	dereference is needed because a subtype of an access_to_subprogram is
	simply an access-subtype

-------------- next part --------------
Index: sem_res.adb
===================================================================
--- sem_res.adb	(revision 138672)
+++ sem_res.adb	(working copy)
@@ -4696,14 +4696,15 @@
          end loop;
       end if;
 
-      if Ekind (Etype (Nam)) = E_Access_Subprogram_Type
-         and then Ekind (Typ) /= E_Access_Subprogram_Type
+      if Is_Access_Subprogram_Type (Base_Type (Etype (Nam)))
+         and then not Is_Access_Subprogram_Type (Base_Type (Typ))
          and then Nkind (Subp) /= N_Explicit_Dereference
          and then Present (Parameter_Associations (N))
       then
          --  The prefix is a parameterless function call that returns an
          --  access to subprogram. If parameters are present in the current
-         --  call  add an explicit dereference.
+         --  call  add an explicit dereference. We use the base type here
+         --  because within an instance these may be subtypes.
 
          --  The dereference is added either in Analyze_Call or here. Should
          --  be consolidated ???


More information about the Gcc-patches mailing list