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] Anonymous access components that denote tasks


In Ada 2012 it is possible to complete an incomplete type with a record one
of whose components is an anonymous access to task initialized with an
allocator. The analysis of the allocator in the init_proc for the type creates
an anonymous access that requires a master id. This must be obtained from the
added formal of the init_proc, using the master renaming machinery.

Compiling and executing main.adb must yield:

      Yeah

---
with P; use P;
procedure Main is
   THing : T;
begin
   Thing.R.Here;
end;
---
pragma Ada_2012;
package P is
   type T;
   task type RT (Self : not null access T) is
      entry Here;
   end;

   type T is tagged limited record
      R : access RT := new  RT (T'Unrestricted_Access);
      Name : String (1..4) := "Yeah";
   end record;
end P;
---
with Text_IO; use Text_IO;
package body P is
   task body RT is
      begin
         accept  Here do
            Put_Line (Self.Name);
         end;
      end;
end P;

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

2013-04-24  Ed Schonberg  <schonberg@adacore.com>

	* exp_ch4.adb (Expand_N_Allocator):  If the designated object
	has tasks, and the pointer type is an itype that has no master
	id, create a master renaming in the current context, which can
	only be an init_proc.

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]