]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Ada] Fix bogus "too late" error with nested generics and inlining
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 19 Sep 2019 08:14:28 +0000 (08:14 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 19 Sep 2019 08:14:28 +0000 (08:14 +0000)
commite3baf4c34c5e4cf584cd48fee128d074bdae817e
treec89237b2bf638a5f295172469f9425fb024ffe04
parentac42ccd18bdc5b544c858129475cb93b5a5a3594
[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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@275953 138bc75d-0d04-0410-961f-82ee72b054a4
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]