===================================================================
@@ -2124,7 +2124,7 @@
return Pack_Decl;
end Build_Local_Package;
- -- Start of processing for Analyze_Formal_Package
+ -- Start of processing for Analyze_Formal_Package_Declaration
begin
Text_IO_Kludge (Gen_Id);
@@ -2182,6 +2182,25 @@
end if;
end if;
+ -- Check that name of formal package does not hide name of generic,
+ -- or its leading prefix. This check must be done separately because
+ -- the name of the generic has already been analyzed.
+
+ declare
+ Gen_Name : Entity_Id;
+
+ begin
+ Gen_Name := Gen_Id;
+ while Nkind (Gen_Name) = N_Expanded_Name loop
+ Gen_Name := Prefix (Gen_Name);
+ end loop;
+ if Chars (Gen_Name) = Chars (Pack_Id) then
+ Error_Msg_NE
+ ("& is hidden within declaration of formal package",
+ Gen_Id, Gen_Name);
+ end if;
+ end;
+
if Box_Present (N)
or else No (Generic_Associations (N))
or else Nkind (First (Generic_Associations (N))) = N_Others_Choice