end if;
end if;
- if Subtype_Mark (Def) in Empty | Error then
- pragma Assert (Serious_Errors_Detected > 0);
+ if Serious_Errors_Detected > 0 then
-- avoid passing bad argument to Entity
return;
end if;
end if;
Parent_Type := Find_Type_Of_Subtype_Indic (Indic);
+ if No (Parent_Type) then
+ pragma Assert (Serious_Errors_Detected > 0);
+ goto Leave;
+ end if;
+
Parent_Base := Base_Type (Parent_Type);
if Parent_Type = Any_Type or else Etype (Parent_Type) = Any_Type then
Act_List : List_Id;
Expr : Node_Id;
Inst_Id : Entity_Id;
+ Par : Node_Id;
+ Prev_Par : Node_Id;
begin
+ Prev_Par := N;
+ Par := Parent (N);
+
+ -- A structural instance cannot be used as a formal package with the
+ -- current implementation of structural instantiation.
+
+ while Present (Par) loop
+ if Nkind (Par) in N_Generic_Declaration
+ and then Is_List_Member (Prev_Par)
+ and then
+ Generic_Formal_Declarations (Par) = List_Containing (Prev_Par)
+ then
+ Error_Msg_N
+ ("structural instantiation cannot be used in generic formal"
+ & " part", N);
+ Rewrite (N,
+ Make_Raise_Program_Error (Sloc (N),
+ Reason => PE_Explicit_Raise));
+ Analyze (N);
+ return;
+
+ else
+ -- Prevent the search from going too far
+
+ exit when Is_Statement (Par)
+ or else Is_Body_Or_Package_Declaration (Par);
+ end if;
+
+ Prev_Par := Par;
+ Par := Parent (Par);
+ end loop;
+
Act_List := New_List;
Expr := First (Expressions (N));
while Present (Expr) loop