[Ada] Spurious visibility error in a nested instance with formal package
authorEd Schonberg <schonberg@adacore.com>
Tue, 22 May 2018 13:23:46 +0000 (13:23 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 22 May 2018 13:23:46 +0000 (13:23 +0000)
commit651822aec7caa0ed1aa8cb3dfb07a380b4595b08
treee6e5513bfff1627d63e13e3e49a4929762591082
parent41ff70d9a5c91c3540d3fdb08ddc58d1e1d00eab
[Ada] Spurious visibility error in a nested instance with formal package

This patch fixes a spurious visibility error with a nested instance of a
generic unit with a formal package, when the actual for it is a formal
package PA of an enclosing generic, and there are subsequent uses of the
formals of PA in that generic unit.

2018-05-22  Ed Schonberg  <schonberg@adacore.com>

gcc/ada/

* einfo.ads, einfo.adb: New attribute Hidden_In_Formal_Instance,
defined on packages that are actuals for formal packages, in order to
set/reset the visibility of the formals of a formal package with given
actuals, when there are subsequent uses of those formals in the
enclosing generic, as required by RN 12.7 (10).
* atree.ads, atree.adb: Add operations for Elist30.
* atree.h: Add Elist30.
* sem_ch12.adb (Analyze_Formal_Package_Instantiation): Collect formals
that are not defaulted and are thus not visible within the current
instance.
(Check_Formal_Packages): Reset visibility of formals of a formal
package that are not defaulted, on exit from current instance.

gcc/testsuite/

* gnat.dg/gen_formal_pkg.adb, gnat.dg/gen_formal_pkg_a.ads,
gnat.dg/gen_formal_pkg_b.ads, gnat.dg/gen_formal_pkg_w.ads: New
testcase.

From-SVN: r260520
12 files changed:
gcc/ada/ChangeLog
gcc/ada/atree.adb
gcc/ada/atree.ads
gcc/ada/atree.h
gcc/ada/einfo.adb
gcc/ada/einfo.ads
gcc/ada/sem_ch12.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/gen_formal_pkg.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/gen_formal_pkg_a.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/gen_formal_pkg_b.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/gen_formal_pkg_w.ads [new file with mode: 0644]