aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/inline.adb
diff options
context:
space:
mode:
authorPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2017-12-15 10:21:24 +0000
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>2017-12-15 10:21:24 +0000
commitc581c5205ae33fdf22ec27cd30047dd45abfb085 (patch)
tree431fe8c09d32345713b3912483edaa98cb899423 /gcc/ada/inline.adb
parent56af86884f7795f5b77544744cd2e0ad825fcdde (diff)
downloadgcc-c581c5205ae33fdf22ec27cd30047dd45abfb085.zip
gcc-c581c5205ae33fdf22ec27cd30047dd45abfb085.tar.gz
gcc-c581c5205ae33fdf22ec27cd30047dd45abfb085.tar.bz2
exp_unst.adb (Unnest_Subprograms): Nothing to do if the main unit is a generic package body.
gcc/ada/ 2017-12-15 Ed Schonberg <schonberg@adacore.com> * exp_unst.adb (Unnest_Subprograms): Nothing to do if the main unit is a generic package body. Unnesting is only an issue when generating code, and if the main unit is generic then nested instance bodies have not been created and analyzed, and unnesting will crash in the absence of those bodies, 2017-12-15 Hristian Kirtchev <kirtchev@adacore.com> * inline.adb (Add_Inlined_Body): Do not add a function which is completed by an expression function defined in the same context as the initial declaration because the completing body is not in a package body. (Is_Non_Loading_Expression_Function): New routine. 2017-12-15 Hristian Kirtchev <kirtchev@adacore.com> * debug.adb: Move the functionality of -gnatdL to -gnatd_i. Restore the behavior of -gnatdL from before revision 255412. * sem_elab.adb: Update the section of compiler switches. (Build_Call_Marker): Do not create a marker for a call which originates from an expanded spec or body of an instantiated gener, does not invoke a generic formal subprogram, the target is external to the instance, and -gnatdL is in effect. (In_External_Context): New routine. (Process_Conditional_ABE_Activation_Impl): Update the uses of -gnatdL and associated flag. (Process_Conditional_ABE_Call): Update the uses of -gnatdL and associated flag. * switch-c.adb (Scan_Front_End_Switches): Switch -gnatJ now sets switch -gnatd_i. * exp_unst.adb: Minor typo fixes and edits. 2017-12-15 Ed Schonberg <schonberg@adacore.com> * sem_ch6.adb (Possible_Freeze): Do not set Delayed_Freeze on an subprogram instantiation, now that the enclosing wrapper package carries an explicit freeze node. THis prevents freeze nodes for the subprogram for appearing in the wrong scope. This is relevant when the generic subprogram has a private or incomplete formal type and the instance appears within a package that declares the actual type for the instantiation, and that type has itself a delayed freeze. 2017-12-15 Patrick Bernardi <bernardi@adacore.com> * doc/gnat_ugn/gnat_and_program_execution.rst: Removed references to the environment variable GNAT_STACK_LIMIT from the Stack Overflow Checking section as it is no longer used by any of our supported targets. gcc/testsuite/ 2017-12-15 Hristian Kirtchev <kirtchev@adacore.com> * gnat.dg/expr_func_main.adb, gnat.dg/expr_func_pkg.ads, gnat.dg/expr_func_pkg.adb: New testcase. 2017-12-15 Hristian Kirtchev <kirtchev@adacore.com> * gnat.dg/abe_pkg.adb, gnat.dg/abe_pkg.ads: New testcase. 2017-12-15 Ed Schonberg <schonberg@adacore.com> * gnat.dg/subp_inst.adb, gnat.dg/subp_inst_pkg.adb, gnat.dg/subp_inst_pkg.ads: New testcase. From-SVN: r255683
Diffstat (limited to 'gcc/ada/inline.adb')
-rw-r--r--gcc/ada/inline.adb63
1 files changed, 60 insertions, 3 deletions
diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb
index f97fce7..072a4e5 100644
--- a/gcc/ada/inline.adb
+++ b/gcc/ada/inline.adb
@@ -298,10 +298,65 @@ package body Inline is
-- Inline_Package means that the call is considered for inlining and
-- its package compiled and scanned for more inlining opportunities.
+ function Is_Non_Loading_Expression_Function
+ (Id : Entity_Id) return Boolean;
+ -- Determine whether arbitrary entity Id denotes a subprogram which is
+ -- either
+ --
+ -- * An expression function
+ --
+ -- * A function completed by an expression function where both the
+ -- spec and body are in the same context.
+
function Must_Inline return Inline_Level_Type;
-- Inlining is only done if the call statement N is in the main unit,
-- or within the body of another inlined subprogram.
+ ----------------------------------------
+ -- Is_Non_Loading_Expression_Function --
+ ----------------------------------------
+
+ function Is_Non_Loading_Expression_Function
+ (Id : Entity_Id) return Boolean
+ is
+ Body_Decl : Node_Id;
+ Body_Id : Entity_Id;
+ Spec_Decl : Node_Id;
+
+ begin
+ -- A stand-alone expression function is transformed into a spec-body
+ -- pair in-place. Since both the spec and body are in the same list,
+ -- the inlining of such an expression function does not need to load
+ -- anything extra.
+
+ if Is_Expression_Function (Id) then
+ return True;
+
+ -- A function may be completed by an expression function
+
+ elsif Ekind (Id) = E_Function then
+ Spec_Decl := Unit_Declaration_Node (Id);
+
+ if Nkind (Spec_Decl) = N_Subprogram_Declaration then
+ Body_Id := Corresponding_Body (Spec_Decl);
+
+ if Present (Body_Id) then
+ Body_Decl := Unit_Declaration_Node (Body_Id);
+
+ -- The inlining of a completing expression function does
+ -- not need to load anything extra when both the spec and
+ -- body are in the same context.
+
+ return
+ Was_Expression_Function (Body_Decl)
+ and then Parent (Spec_Decl) = Parent (Body_Decl);
+ end if;
+ end if;
+ end if;
+
+ return False;
+ end Is_Non_Loading_Expression_Function;
+
-----------------
-- Must_Inline --
-----------------
@@ -415,10 +470,12 @@ package body Inline is
Set_Needs_Debug_Info (E, False);
end if;
- -- If the subprogram is an expression function, then there is no need to
- -- load any package body since the body of the function is in the spec.
+ -- If the subprogram is an expression function, or is completed by one
+ -- where both the spec and body are in the same context, then there is
+ -- no need to load any package body since the body of the function is
+ -- in the spec.
- if Is_Expression_Function (E) then
+ if Is_Non_Loading_Expression_Function (E) then
Set_Is_Called (E);
return;
end if;