]> git.ipfire.org Git - thirdparty/gcc.git/commit
[Ada] Inlining of renamed subprogram instances in package body
authorpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 26 Sep 2018 09:17:36 +0000 (09:17 +0000)
committerpmderodat <pmderodat@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 26 Sep 2018 09:17:36 +0000 (09:17 +0000)
commit6591af037f92df27d5fc710c0c4e4acb94e7883b
tree06ad6a863eb3475eb4ecf7f60ebe80b5ad62cdf9
parentd86fe1242ca66f732a3aaa0e0e7ee29a930a851a
[Ada] Inlining of renamed subprogram instances in package body

This fixes a small discrepancy in the handling of renamed subprograms
declared in a package body, between those originally a regular
subprogram and those an instance of a generic subprogram, the latter
being slightly hindered.

The difference comes from the setting of the Is_Public flag, which was
more conservative in the latter case because instantiations of generic
subprograms are done in compiler-generated local packages.

It is eliminated by allowing Has_Referencer to recurse into nested
packages, but only if they are themselves not instances of generic
packages.

The compiler must now fully inline Doit_I into Doit at -O2 in:

package P is

  generic procedure Doit_G;

  procedure Doit;
end P;

package body P is

  N : Natural := 0;

  procedure Doit_G is
  begin
    N := 1;
  end Doit_G;

  procedure Doit_I is new Doit_G;

  procedure Doit renames Doit_I;

end P;

2018-09-26  Eric Botcazou  <ebotcazou@adacore.com>

gcc/ada/

* sem_ch7.adb (Has_Referencer): Remove Top_Level parameter and
add In_Nested_Instance and
Has_Outer_Referencer_Of_Non_Subprograms parameters.  Rename
Has_Non_Subprograms_Referencer variable into
Has_Referencer_Of_Non_Subprograms and initialize it with the new
third parameter.  Adjust recursive calls and to the renaming.
Replace test on Top_Level with test on In_Nested_Instance to
decide whether to clear the Is_Public flag on entities.
(Hide_Public_Entities): Adjust call to Has_Referencer.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@264615 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ada/ChangeLog
gcc/ada/sem_ch7.adb