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] Improve issues with interfaces and aggregates


Test on i686-linux, committed on trunk.

If a record component has an access definition, we generate an anonymous
access type for it and rewrite the component definition with a subtype
indication to simplify semantic processing. For tree navigation purposes
in ASIS, we must ensure that the original tree structure can be recovered.

In Ada 2005, aggregates can be used to initialize objects of a limited
type. If the type has defaulted discriminants, the actual subtype of the
object is obtained from the aggregate itself and not from the defaults.
The following must compile quietly:
--
package P is
   type Obj1 is tagged null record;
   type Obj2 is new Obj1 with null record;
   type Ptr1 is access all Obj1;
   type Ptr2 is access all Obj2;
   P1 : Ptr1 := new Obj1;
   P2 : Ptr2 := new Obj2;
   type Rec (D : access Obj1'class := P1) is limited record
      Yes : Boolean;
   end record;
   Thing : Rec := (P2, True);
end;

Another consequence of AI-419 on the inheritance of limitedness for
interfaces. We maintain two separate flags: Is_Limited_Record indicates
that a type has "limited" in its declaration.  Is_Limited_Interface
indicates that the type can be implemented with a task, protected, or
otherwise limited type. Both flags must be maintained consistently.
The following must compile quietly in Ada 2005 mode:
--
package P is
   type I is limited interface;
   type J is limited interface and I;
   type L is limited null record;
   type T is limited new J with record
      An_L : L;
   end record;
end;

2006-02-17  Javier Miranda  <miranda@adacore.com>
	    Ed Schonberg  <schonberg@adacore.com>

	* sem_ch3.adb (Build_Discriminated_Subtype): In case of concurrent
	type we cannot inherit the primitive operations; we inherit the
	Corresponding_Record_Type (which has the list of primitive operations).
	(Check_Anonymous_Access_Types): When creating anonymous access types for
	access components, use Rewrite in order to preserve the tree structure,
	for ASIS use.
	(Analyze_Object_Declaration): For limited types with access
	discriminants with defaults initialized by an aggregate, obtain
	subtype from aggregate as for other mutable types.
	(Derived_Type_Declaration): If the derived type is a limited interface,
	set the corresponding flag (Is_Limited_Record is not sufficient).

Attachment: difs.12
Description: Text document


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