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] Master entities in Ada2005


When a type includes tasks, a master entity is created in the scope, to be
used by the runtime during activation. In general the master is the immedidate
scope in which the type is declared, but in Ada2005, in the presence of
synchronized classwide interfaces, the immediate scope of an anonymous access
type may be a transient scope, which has no run-time presence. In this case,
the scope of the master is the innermost scope that comes from source.

The following must compile quietly:

---
package Pack09 is

  type Node_Type is limited interface;
  type Node_Ref is access all Node_Type'Class;

  function Parent (Node : Node_Type) return Node_Ref is abstract;

  type Node_Cursor is limited interface;

  function Has_Element (Position : Node_Cursor) return Boolean is abstract;
  function Element (Position : Node_Cursor) return Node_Ref is abstract;
  function Next (Position : Node_Cursor) return Node_Cursor is abstract;

  function First_Child (Node : Node_Type) return Node_Cursor'Class is abstract;

  function F (Node : Node_Ref) return Boolean;

end Pack09;
---
package body Pack09 is

  function F (Node : Node_Ref) return Boolean is
  begin
     return Node.Parent.First_Child.Element = Node
       and then not Node.Parent.First_Child.Next.Has_Element;
  end F;
end Pack09; 

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

2010-09-09  Ed Schonberg  <schonberg@adacore.com>

	* exp_ch9.ads (Find_Master_Scope): New function, extracted from
	Build_Master_Entity, to find the proper scope for the master entity of
	a type that may contain tasks, in the presence of transient scopes.
	* exp_ch9.adb (Build_Master_Entity) Use new function.
	* exp_ch3.adb (Build_Class_Wide_Master): ditto.

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]