Comments

In general it is illegal for a type derived from a formal limited type to be
non-limited. AI05-096 makes an exception to this rule: the derivation is legal
if it appears in the private part of the generic, and the formal type is not
tagged. If the type is tagged, the legality check must be applied to the
private part of the package.
The following must compile quietly:
procedure Inst is
generic
type Lim is limited private;
package Gen is
private
type New_Lim is limited new Lim;
end Gen;
package New_Gen is new Gen (Integer);
begin
null;
end;
The following must be rejected with the message:
inst2.adb:9:04: instantiation error at line 6
inst2.adb:9:04: parent type "Lim" of limited type must be limited
---
procedure Inst2 is
generic
type Lim is tagged limited private;
package Gen is
private
type New_Lim is limited new Lim with null record;
end Gen;
type Rec is tagged null record;
package New_Gen is new Gen (Rec);
begin
null;
end;
Tested on x86_64-pc-linux-gnu, committed on trunk
2010-10-08 Ed Schonberg <schonberg@adacore.com>
* sem_ch3.adb (Derived_Type_Declaration): In the private part of an
instance, it is legal to derive from a non-limited actual when the
formal type is untagged limited.
* sem_ch12.adb (Instantiate_Type): For a formal private type, use
analyzed formal as Generic_Parent_Type, to simplify later checks.