diff options
author | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-18 10:46:40 +0000 |
---|---|---|
committer | charlet <charlet@138bc75d-0d04-0410-961f-82ee72b054a4> | 2016-04-18 10:46:40 +0000 |
commit | c41e404dd637e56ba3c70e607b05a1663071e7f2 (patch) | |
tree | 6b79a0b34a4ee6a589bdc031cfa4e17af7e81b98 /gcc/ada/exp_ch6.adb | |
parent | 82eb6a0d208de0e1caed46bcf5a9622cf48cfee0 (diff) | |
download | gcc-c41e404dd637e56ba3c70e607b05a1663071e7f2.tar.gz |
2016-04-18 Hristian Kirtchev <kirtchev@adacore.com>
* namet.adb, namet.ads, exp_unst.adb: Minor reformatting.
2016-04-18 Hristian Kirtchev <kirtchev@adacore.com>
* sem_eval.adb (Choice_Matches): Check the expression
against the predicate values when the choice denotes a
subtype with a static predicate.
(Eval_Membership_Op): Code cleanup. Remove the suspicious guard which
tests for predicates.
(Is_OK_Static_Subtype): A subtype with a dynamic predicate
is not static. (Is_Static_Subtype): A subtype with a dynamic
predicate is not static.
* sem_eval.ads (Is_OK_Static_Subtype): Update the comment on usage.
(Is_Static_Subtype): Update the comment on usage.
2016-04-18 Hristian Kirtchev <kirtchev@adacore.com>
* sem_prag.adb (Analyze_Input_Item): Allow
generic formals to appear as initialization items.
2016-04-18 Ed Schonberg <schonberg@adacore.com>
* sem_ch13.adb (Analyze_Stream_TSS_Definition,
Has_Good_Profile): Additional error message to indicate that
the second parameter of the subprogram must be a first subtype.
2016-04-18 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb (Analyze_Subprogram_Body_Helper, Is_Inline_Pragma):
Use the pragma lookahead that determines whether a subprogram
is to be inlined, when some level of backend optimization is
required.
* sem_ch12.ads, sem_ch12.adb (Add_Pending_Instantiation): Factorize
code used to create an instance body when needed for inlining.
* exp_ch6.adb (Expand_Call): When a call is to be inlined, and the
call appears within an instantiation that is not a compilation
unit, add a pending instantiation for the enclosing instance,
so the backend can inline in turn the calls contained in the
inlined body.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@235124 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ada/exp_ch6.adb')
-rw-r--r-- | gcc/ada/exp_ch6.adb | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb index bdde498306a..a72bbe18d0a 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -59,6 +59,7 @@ with Sem; use Sem; with Sem_Aux; use Sem_Aux; with Sem_Ch6; use Sem_Ch6; with Sem_Ch8; use Sem_Ch8; +with Sem_Ch12; use Sem_Ch12; with Sem_Ch13; use Sem_Ch13; with Sem_Dim; use Sem_Dim; with Sem_Disp; use Sem_Disp; @@ -3898,6 +3899,50 @@ package body Exp_Ch6 is then Add_Inlined_Body (Subp, Call_Node); + -- If the inlined call appears within an instantiation and some + -- level of optimization is required, ensure that the enclosing + -- instance body is available so that the back-end can actually + -- perform the inlining. + + if In_Instance + and then Comes_From_Source (Subp) + and then Optimization_Level > 0 + then + declare + Inst : Entity_Id; + Decl : Node_Id; + + begin + Inst := Scope (Subp); + + -- Find enclosing instance. + + while Present (Inst) and then Inst /= Standard_Standard loop + exit when Is_Generic_Instance (Inst); + Inst := Scope (Inst); + end loop; + + if Present (Inst) and then Is_Generic_Instance (Inst) then + Set_Is_Inlined (Inst); + Decl := Unit_Declaration_Node (Inst); + + -- Do not add a pending instantiation if the body exits + -- already, or if the instance is a compilation unit, or + -- the instance node is missing. + + if Present (Corresponding_Body (Decl)) + or else Nkind (Parent (Decl)) = N_Compilation_Unit + or else No (Next (Decl)) + then + null; + + else + Add_Pending_Instantiation (Next (Decl), Decl); + end if; + end if; + end; + end if; + -- Front end expansion of simple functions returning unconstrained -- types (see Check_And_Split_Unconstrained_Function). Note that the -- case of a simple renaming (Body_To_Inline in N_Entity above, see |