Commit 46fa6b05 by Ed Schonberg Committed by Pierre-Marie de Rodat

[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
parent 231ef54b
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
......
......@@ -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
......
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.
......
generic
package Generic2.Child is
private
type My_Int is new Int;
end Generic2.Child;
-- { dg-do compile }
package body Generic2.IO_Any is
procedure Dummy is null;
end Generic2.IO_Any;
\ No newline at end of file
with Generic2.Child;
generic
package Generic2.IO_Any is
package V1 is new Generic2.Child;
procedure Dummy;
end Generic2.IO_Any;
generic
package Generic2 is
private
type Int is new Integer;
end Generic2;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment