elsif Is_Private_Type (Btype) then
- -- If Ent occurs in the completion of a limited private type, then
- -- look for the word "limited" in the full view.
+ -- If Ent occurs in the completion of a private type, then
+ -- look for the word "limited" in the full view.
if Nkind (Parent (Ent)) = N_Full_Type_Declaration
- and then Nkind (Type_Definition (Parent (Ent))) =
- N_Record_Definition
+ and then Nkind (Type_Definition (Parent (Ent))) in
+ N_Record_Definition | N_Derived_Type_Definition
and then Limited_Present (Type_Definition (Parent (Ent)))
then
return True;
OldD : constant Boolean :=
Present (Expression (Parent (Old_Discr)));
+ function Has_Tagged_Limited_Partial_View
+ (Typ : Entity_Id) return Boolean;
+ -- Returns True iff Typ has a tagged limited partial view.
+
+ -------------------------------------
+ -- Has_Tagged_Limited_Partial_View --
+ -------------------------------------
+
+ function Has_Tagged_Limited_Partial_View
+ (Typ : Entity_Id) return Boolean
+ is
+ Priv : constant Entity_Id := Incomplete_Or_Partial_View (Typ);
+ begin
+ return Present (Priv)
+ and then not Is_Incomplete_Type (Priv)
+ and then Is_Tagged_Type (Priv)
+ and then Limited_Present (Parent (Priv));
+ end Has_Tagged_Limited_Partial_View;
+
begin
if NewD or OldD then
N_Access_Definition
and then not Is_Immutably_Limited_Type
(Defining_Identifier (N))
+
+ -- Check for a case that would be awkward to handle in
+ -- Is_Immutably_Limited_Type (because sem_aux can't
+ -- "with" sem_util).
+
+ and then not Has_Tagged_Limited_Partial_View
+ (Defining_Identifier (N))
then
Error_Msg_N
("(Ada 2005) default value for access discriminant "