[Ada] Spurious visibility error in generic child unit

2019-09-19  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

	* sem_ch7.adb (Install_Parent_Private_Declarations): If a
	generic child unit is instantiated within a sibling child unit,
	the analysis of its private part requires that the private part
	of the ancestor be available, as is done when the context
	includes an instance of the ancestor.

gcc/testsuite/

	* gnat.dg/generic2-child.ads, gnat.dg/generic2-io_any.adb,
	gnat.dg/generic2-io_any.ads, gnat.dg/generic2.ads: New testcase.

From-SVN: r275949
This commit is contained in:
Ed Schonberg 2019-09-19 08:14:08 +00:00 committed by Pierre-Marie de Rodat
parent 231ef54b96
commit 46fa6b050e
7 changed files with 49 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2019-09-19 Ed Schonberg <schonberg@adacore.com>
* sem_ch7.adb (Install_Parent_Private_Declarations): If a
generic child unit is instantiated within a sibling child unit,
the analysis of its private part requires that the private part
of the ancestor be available, as is done when the context
includes an instance of the ancestor.
2019-09-19 Yannick Moy <moy@adacore.com>
* inline.adb (Can_Be_Inlined_In_GNATprove_Mode): Add special

View File

@ -1508,9 +1508,21 @@ package body Sem_Ch7 is
Inst_Par := Renamed_Entity (Inst_Par);
end if;
Gen_Par :=
Generic_Parent
(Specification (Unit_Declaration_Node (Inst_Par)));
-- The instance may appear in a sibling generic unit, in
-- which case the prefix must include the common (generic)
-- ancestor, which is treated as a current instance.
if Inside_A_Generic
and then Ekind (Inst_Par) = E_Generic_Package
then
Gen_Par := Inst_Par;
pragma Assert (In_Open_Scopes (Gen_Par));
else
Gen_Par :=
Generic_Parent
(Specification (Unit_Declaration_Node (Inst_Par)));
end if;
-- Install the private declarations and private use clauses
-- of a parent instance of the child instance, unless the

View File

@ -1,3 +1,8 @@
2019-09-19 Ed Schonberg <schonberg@adacore.com>
* gnat.dg/generic2-child.ads, gnat.dg/generic2-io_any.adb,
gnat.dg/generic2-io_any.ads, gnat.dg/generic2.ads: New testcase.
2019-09-19 Yannick Moy <moy@adacore.com>
* gnat.dg/global2.adb, gnat.dg/global2.ads: New testcase.

View File

@ -0,0 +1,5 @@
generic
package Generic2.Child is
private
type My_Int is new Int;
end Generic2.Child;

View File

@ -0,0 +1,5 @@
-- { dg-do compile }
package body Generic2.IO_Any is
procedure Dummy is null;
end Generic2.IO_Any;

View File

@ -0,0 +1,6 @@
with Generic2.Child;
generic
package Generic2.IO_Any is
package V1 is new Generic2.Child;
procedure Dummy;
end Generic2.IO_Any;

View File

@ -0,0 +1,5 @@
generic
package Generic2 is
private
type Int is new Integer;
end Generic2;