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] Move error checks for eliminated subprogram references to the front end


Currently error checks for invalid references to eliminated subprograms
in calls and attributes are performed in the back end, but this means
duplicating these checks in the case of non-gcc back ends (AAMP,.NET,JVM).
The checks are now moved to the front end, done at the point of call
resolution and analysis of attributes. A new error checking routine is
added that accounts for going up the alias chain and excludes flagging
of references nested within generics and eliminated subprograms.


The test below must report the following errors:

subp_elim_errors.adb:24:04:
 cannot reference subprogram "Proc" eliminated at subp_elim_errors.ads:1
subp_elim_errors.adb:26:15:
 cannot reference subprogram "Proc" eliminated at subp_elim_errors.ads:1
subp_elim_errors.adb:28:15:
 cannot reference subprogram "Proc" eliminated at subp_elim_errors.ads:1
subp_elim_errors.adb:30:15:
 cannot reference subprogram "Proc" eliminated at subp_elim_errors.ads:1


pragma Eliminate (Subp_Elim_Errors, Proc);

package Subp_Elim_Errors is

   procedure Proc;

end Subp_Elim_Errors;

with System;

package body Subp_Elim_Errors is

   type Acc_Proc is access procedure;

   procedure Proc is
   begin
      null;
   end Proc;

   procedure Pass_Proc (P : Acc_Proc) is
   begin
      P.all;
   end Pass_Proc;

   procedure Pass_Proc (P : System.Address) is
   begin
      null;
   end Pass_Proc;

begin
   Proc;                      -- ERROR: call to eliminated subprogram

   Pass_Proc (Proc'Access);   -- ERROR: 'Access of eliminated subprogram

   Pass_Proc (Proc'Address);  -- ERROR: 'Address of eliminated subprogram

   Pass_Proc (Proc'Code_Address);  -- ERROR: 'Code_Address of eliminated subprogram
end Subp_Elim_Errors;

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

2009-04-20  Gary Dismukes  <dismukes@adacore.com>

	* sem_elim.ads (Check_For_Eliminated_Subprogram): New procedure for
	checking for references to eliminated subprograms that should be
	flagged.
	(Eliminate_Error_Message): Update comment to say "references" rather
	than "calls" (since attribute cases are handled here as well).

	* sem_elim.adb (Check_For_Eliminated_Subprogram): New procedure for
	checking for references to eliminated subprograms that should be
	flagged.  Add with and use of Sem and Sem_Util.

	* sem_res.adb (Resolve_Call): Reject calls to eliminated subprograms.
	Add with and use of Sem_Elim.

	* sem_attr.adb (Analyze_Access_Attribute): Reject access attributes
	applied to eliminated subprograms.
	(Analyze_Attribute): Reject 'Address and 'Code_Address applied to
	eliminated subprograms.
	Add with and use of Sem_Elim.

	* sem_disp.adb (Check_Dispatching_Call): Remove error check for calls
	to eliminated subprograms, now handled during Resolve_Call.
	Remove with and use of Sem_Elim.

	* exp_disp.adb (Make_DT): Get Ultimate_Alias of primitive before
	testing Is_Eliminated, for proper handling of primitive derived from
	eliminated subprograms.

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]