[Ada] Fix spurious error on nested instantiation with inlining
authorEric Botcazou <ebotcazou@adacore.com>
Tue, 13 Aug 2019 08:06:39 +0000 (08:06 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 13 Aug 2019 08:06:39 +0000 (08:06 +0000)
commitd71e9fb2a5f1d55a065e3b50ee5fb2a34e75ead7
treefbd2a073166c4fd599360c1c5d693860f419b9e4
parent7225a4797180b6dc515760b0c123001cda2b66a2
[Ada] Fix spurious error on nested instantiation with inlining

This prevents the compiler from issuing a spurious error in a convoluted
case where a child generic package declared in an enclosing parent
generic package, which contains a second child generic package, contains
an inlined subprogram and the second child generic package contains an
instantiation of the first, and the enclosing parent generic package is
instantiated with inlining across units enabled (-gnatn[12]).

The problem is that the compiler attempts to instantiate the body of the
first child generic package in the context of the enclosing parent
generic package, instead of doing it in the context of the instantiation
of the parent generic package, because of the presence of the inlined
subprogram.

2019-08-13  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* exp_ch6.adb (Expand_Call_Helper): If back-end inlining is
enabled, also instantiate the body of a generic unit containing
a subprogram subject to aspect/pragma Inline_Always at
optimization level zero.
* sem_ch12.adb (Might_Inline_Subp): Minor tweak.
(Analyze_Package_Instantiation): Do not instantiate the package
body because of inlining considerations if the instantiation is
done in a generic unit.  Move around similar condition involving
the main unit.  Add test on Back_End_Inlining to processing for
front-end inlining.

gcc/testsuite/

* gnat.dg/generic_inst8.adb, gnat.dg/generic_inst8.ads,
gnat.dg/generic_inst8_g.adb, gnat.dg/generic_inst8_g.ads: New
testcase.

From-SVN: r274336
gcc/ada/ChangeLog
gcc/ada/exp_ch6.adb
gcc/ada/sem_ch12.adb
gcc/testsuite/ChangeLog
gcc/testsuite/gnat.dg/generic_inst8.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/generic_inst8.ads [new file with mode: 0644]
gcc/testsuite/gnat.dg/generic_inst8_g.adb [new file with mode: 0644]
gcc/testsuite/gnat.dg/generic_inst8_g.ads [new file with mode: 0644]