diff options
author | Piotr Trojanek <trojanek@adacore.com> | 2022-12-20 17:39:04 +0100 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-01-05 15:30:02 +0100 |
commit | 9ff806899bfa38ade0bddbdfb413ca3444425bcf (patch) | |
tree | b6a96085752399459cf306ff655e65a09abac606 | |
parent | 6147feb54c7473033c5e9344fdd834c417820af4 (diff) | |
download | gcc-9ff806899bfa38ade0bddbdfb413ca3444425bcf.zip gcc-9ff806899bfa38ade0bddbdfb413ca3444425bcf.tar.gz gcc-9ff806899bfa38ade0bddbdfb413ca3444425bcf.tar.bz2 |
ada: Flag renaming-as-spec as a body to inline
For GNAT the frontend is only inlining subprograms with explicit specs,
including specs completed with renaming-as-body. For GNATprove the
frontend must also inline renamings acting as specs. Otherwise, we will
try to build a body-to-inline with code that is can't handle unusual
subprogram renamings, e.g. those of the form "object.call".
gcc/ada/
* freeze.adb (Build_Renamed_Body): Rewrite subprogram renaming to
subprogram declaration early and then set the Body_To_Inling flag.
-rw-r--r-- | gcc/ada/freeze.adb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/gcc/ada/freeze.adb b/gcc/ada/freeze.adb index a3ab685..0e55f14 100644 --- a/gcc/ada/freeze.adb +++ b/gcc/ada/freeze.adb @@ -473,6 +473,12 @@ package body Freeze is Set_Is_Overloaded (Call_Name, False); end if; + if Nkind (Decl) /= N_Subprogram_Declaration then + Rewrite (N, + Make_Subprogram_Declaration (Loc, + Specification => Specification (N))); + end if; + -- For simple renamings, subsequent calls can be expanded directly as -- calls to the renamed entity. The body must be generated in any case -- for calls that may appear elsewhere. This is not done in the case @@ -480,7 +486,6 @@ package body Freeze is -- body has not been built yet. if Ekind (Old_S) in E_Function | E_Procedure - and then Nkind (Decl) = N_Subprogram_Declaration and then not Is_Generic_Instance (Old_S) then Set_Body_To_Inline (Decl, Old_S); @@ -655,12 +660,6 @@ package body Freeze is Statements => New_List (Call_Node))); end if; - if Nkind (Decl) /= N_Subprogram_Declaration then - Rewrite (N, - Make_Subprogram_Declaration (Loc, - Specification => Specification (N))); - end if; - -- Link the body to the entity whose declaration it completes. If -- the body is analyzed when the renamed entity is frozen, it may -- be necessary to restore the proper scope (see package Exp_Ch13). |