then
Error_Msg_N ("premature usage of incomplete type", Def);
- elsif Is_Internal (Designated_Type (T)) then
+ elsif not Is_Entity_Name (Subtype_Indication (Def)) then
Error_Msg_N
("only a subtype mark is allowed in a formal", Def);
end if;
procedure Mark_Context (Inst_Decl : Node_Id; Gen_Decl : Node_Id) is
Inst_CU : constant Unit_Number_Type := Get_Code_Unit (Inst_Decl);
Gen_CU : constant Unit_Number_Type := Get_Source_Unit (Gen_Decl);
+ Inst : Entity_Id := Cunit_Entity (Inst_CU);
Clause : Node_Id;
begin
and then Library_Unit (Clause) = Cunit (Gen_CU)
then
Set_Withed_Body (Clause, Cunit (Gen_CU));
+ return;
end if;
Next (Clause);
end loop;
+
+ -- If the with-clause for the generic unit was not found, it must
+ -- appear in some ancestor of the current unit.
+
+ while Is_Child_Unit (Inst) loop
+ Inst := Scope (Inst);
+ Clause :=
+ First (Context_Items (Parent (Unit_Declaration_Node (Inst))));
+
+ while Present (Clause) loop
+ if Nkind (Clause) = N_With_Clause
+ and then Library_Unit (Clause) = Cunit (Gen_CU)
+ then
+ Set_Withed_Body (Clause, Cunit (Gen_CU));
+ return;
+ end if;
+
+ Next (Clause);
+ end loop;
+ end loop;
end Mark_Context;
---------------------