This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Prefix of 'Address attribute


The prefix of certain attributes references  suvh as 'Address and 'Access is
never interpreted as a function call.  This rule was not properly enforced
when the prefix was an explicit dereference of an access_to_function value.

The following must compile and execute quietly:

with System; use System;
with yyy; use yyy;
procedure Addr is
begin
   if Func'Address /= Func_Addr then
      raise Program_Error;
   end if;

   if Proc'Address /= Proc_Addr then
      raise Program_Error;
   end if;
end;
---
with System; use System;
package Yyy is
   procedure Proc (Param : in Integer);
   function Func  (Param : in Integer) return Integer;

   type Proc_Ptr_T is access procedure (Param : in Integer);
   type Func_Ptr_T is access function (Param : in Integer) return Integer;

   Proc_Ptr : Proc_Ptr_T := Proc'Access;
   Func_Ptr : Func_Ptr_T := Func'Access;

   Proc_Addr : System.Address := Proc_Ptr.all'Address;
   Func_Addr : System.Address := Func_Ptr.all'Address;
end;
---
package body Yyy is

   procedure Proc (Param : in Integer) is begin null; end;
   function Func  (Param : in Integer) return Integer is
   begin
      return 1;
   end;
end;

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

2010-10-05  Ed Schonberg  <schonberg@adacore.com>

	* sem_res.adb (Check_Parameterless_Call): If the prefix of 'Address is
	an explicit dereference of an access to function, the prefix is not
	interpreted as a parameterless call.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]