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] Restriction Static_Dispatch_Tables


This patch implements a new GNAT restriction named Static_Dispatch_Tables,
which is intented to prevent the creation of tagged types whose dispatch
tables cannot be placed in read-only memory.

The following test now compiles with errors.

pragma Restrictions (Static_Dispatch_Tables);

procedure Test_Static_DT is
   package Local is
      type Typ is tagged null record;        --  Test
      procedure Prim (Obj : Typ);
   end;
   package body Local is 
      procedure Prim (Obj : Typ) is
      begin
         null;
      end;
   end;

   Obj : Local.Typ;
begin
   Obj.Prim;
end;

Command: gcc -c test_static_dt.adb
test_static_dt.adb:5:12: violation of restriction
  "Static_Dispatch_Tables" at line 1

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

2017-11-09  Javier Miranda  <miranda@adacore.com>

	* libgnat/s-rident.ads (Static_Dispatch_Tables): New restriction name.
	* exp_disp.adb (Building_Static_DT): Check restriction.
	(Building_Static_Secondary_DT): Check restriction.
	(Make_DT): Initialize the HT_Link to No_Tag.
	* opt.ads (Static_Dispatch_Tables): Rename flag...
	(Building_Static_Dispatch_Tables): ... into this.  This will avoid
	conflict with the restriction name.
	* gnat1drv.adb: Update.
	* exp_aggr.adb (Is_Static_Dispatch_Table_Aggregate): Update.
	* exp_ch3.adb (Expand_N_Object_Declaration): Update.

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]