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] Extension aggregate with ancestor that is a constrained private extension


This patch fixes the handling of extension aggregates when the parent type is
a private extension that constrains a discriminant of the parent.

The following must compile quietly:

with P; use P;
package X is

   type Base_I is interface;
   type Interface_And_Child is new Child_1_3 and Base_I with null record;

   function Copy_No_Clone
     (Object : Interface_And_Child) return access Interface_And_Child;

   type Interface_And_Child_Acc is access all Interface_And_Child'Class;
end X;
---
package body X is

   function Copy_No_Clone
     (Object : Interface_And_Child) return access Interface_And_Child
   is
      Res : Interface_And_Child_Acc :=
        new Interface_And_Child'(Child_1_3 with others => <>);
   begin
      return Res;
   end Copy_No_Clone;
end X;
---
package P is
   type Root_1 (V : Integer) is tagged null record;
   type Child_1_3 is new Root_1 (1) with private;

private
   type Child_1_3 is new Root_1 (1) with null record;
end P;

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

2010-06-17  Ed Schonberg  <schonberg@adacore.com>

	* sem_aggr.adb (Valid_Ancestor_Type): handle properly the case of a
	constrained discriminated parent that is a private type.
	(Analyze_Record_Aggregate): when collecting inherited discriminants,
	handle properly an ancestor type that is a constrained private type.

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]