2020-06-08 Ed Schonberg <schonberg@adacore.com>
gcc/ada/
* par-ch12.adb (P_Formal_Derived_Type_Definition): Handle
properly formal derived types that include aspect
specifications, so that the "with" keyword appears twice in the
formal type declaration.
* sem_ch13.adb (Has_Generic_Parent): Return true if the type
itself is a generic formal.
if Token = Tok_With then
- if Ada_Version >= Ada_2020 and Token /= Tok_Private then
+ if Ada_Version >= Ada_2020 and not Next_Token_Is (Tok_Private) then
+
-- Formal type has aspect specifications, parsed later.
+ -- Otherwise this is a formal derived type. Note that it may
+ -- also include later aspect specifications, as in:
+
+ -- type DT is new T with private with atomic;
+
return Def_Node;
else
function Rep_Item_Too_Early (T : Entity_Id; N : Node_Id) return Boolean is
function Has_Generic_Parent (E : Entity_Id) return Boolean;
- -- Return True if any ancestor is a generic type
+ -- Return True if R or any ancestor is a generic type
------------------------
-- Has_Generic_Parent --
Ancestor_Type : Entity_Id := Etype (E);
begin
+ if Is_Generic_Type (E) then
+ return True;
+ end if;
+
while Present (Ancestor_Type)
and then not Is_Generic_Type (Ancestor_Type)
and then Etype (Ancestor_Type) /= Ancestor_Type