[Ada] Fix bogus "too late" error with nested generics and inlining
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 19 Sep 2019 08:14:28 +0000 (08:14 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Thu, 19 Sep 2019 08:14:28 +0000 (08:14 +0000)
commitd53301c91fe9cfffaa06880ea1e32a9fc9246709
treec89237b2bf638a5f295172469f9425fb024ffe04
parent9e0746fcd5bb14d164d3686b0940ae7129d05231
[Ada] Fix bogus "too late" error with nested generics and inlining

This prevents the compiler from issuing a bogus error about a constant
whose full declaration appears too late, if it is declared in a nested
generic package and instantiated in another nested instantiation, when
the instantiations are done in a unit withed from the main unit and
containing an inlined subprogram, and cross-unit inlining is enabled.

It turns out that, under these very peculiar conditions, the compiler
ends up instantiating the body of the generic package twice, which leads
to various semantic errors, in particular for declarations of constants.

2019-09-19  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* sem_ch12.adb (Instantiate_Package_Body): Check that the body
has not already been instantiated when the body of the parent
was being loaded.

gcc/testsuite/

* gnat.dg/inline21.adb, gnat.dg/inline21_g.ads,
gnat.dg/inline21_h.adb, gnat.dg/inline21_h.ads,
gnat.dg/inline21_q.ads: New testcase.

From-SVN: r275953
gcc/ada/ChangeLog
gcc/ada/sem_ch12.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/inline21.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/inline21_g.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/inline21_h.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/inline21_h.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/inline21_q.ads [new file with mode: 0644]