aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/inline.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2017-09-06 13:56:31 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2017-09-06 13:56:31 +0200
commit66f95f60458a1da2e82c4b879357ebe36fcdb879 (patch)
treec9da704bda48577d1975d5baf566552d6ac64a69 /gcc/ada/inline.adb
parent7ec25b2bf17ebafa1ce9a7066e5e52b9eb7e68d2 (diff)
downloadgcc-66f95f60458a1da2e82c4b879357ebe36fcdb879.zip
gcc-66f95f60458a1da2e82c4b879357ebe36fcdb879.tar.gz
gcc-66f95f60458a1da2e82c4b879357ebe36fcdb879.tar.bz2
[multiple changes]
2017-09-06 Eric Botcazou <ebotcazou@adacore.com> * sem_ch7.adb: Update comment. 2017-09-06 Yannick Moy <moy@adacore.com> * einfo.adb, einfo.ads (Is_Subprogram_Or_Entry): New predicate. * inline.adb (Can_Be_Inlined_In_GNATprove_Mode): Use new function. * sem_util.adb, sem_util.ads (Within_Protected_Type): Renaming with slight modification from Is_Subp_Or_Entry_Inside_Protected, so that applies to any entity. 2017-09-06 Yannick Moy <moy@adacore.com> * sem_ch3.adb (Derived_Type_Declaration): Use Incomplete_Or_Partial_View rather than local Find_Partial_View. 2017-09-06 Javier Miranda <miranda@adacore.com> * g-catiio.ads, g-catiio.adb (Value): Extended to parse an UTC time following ISO-8861. 2017-09-06 Ed Schonberg <schonberg@adacore.com> * sem_dim.adb (Analyze_Dimension): In an instance, a type conversion takes its dimensions from the expression, not from the context type. (Dimensions_Of_Operand): Ditto. 2017-09-06 Ed Schonberg <schonberg@adacore.com> * exp_ch6.adb (Expand_Call_Helper): Do not optimize calls to null procedures when GNAT coverage is used, so that their (empty) bodies are properly covered. 2017-09-06 Bob Duff <duff@adacore.com> * sem_ch13.adb (Resolve_Aspect_Expressions): If the entity is a type with discriminants, make the discriminants directly visible in aspect clauses. 2017-09-06 Ed Schonberg <schonberg@adacore.com> * sem_res.adb (Resolve_Arithmentic_Op): If both operands are Universal_Real and the context is a floating-point type, resolve both operands to the target type. From-SVN: r251783
Diffstat (limited to 'gcc/ada/inline.adb')
-rw-r--r--gcc/ada/inline.adb139
1 files changed, 71 insertions, 68 deletions
diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb
index f023d72..15efcef 100644
--- a/gcc/ada/inline.adb
+++ b/gcc/ada/inline.adb
@@ -1053,7 +1053,7 @@ package body Inline is
-- generic, so that the proper global references are preserved.
-- Note that we do not do this at the library level, because it is not
- -- needed, and furthermore this causes trouble if front end inlining
+ -- needed, and furthermore this causes trouble if front-end inlining
-- is activated (-gnatN).
if In_Instance and then Scope (Current_Scope) /= Standard_Standard then
@@ -1417,7 +1417,7 @@ package body Inline is
-- which typically are not helper subprograms, which also avoids getting
-- spurious messages on calls that cannot be inlined.
- elsif Is_Subp_Or_Entry_Inside_Protected (Id) then
+ elsif Within_Protected_Type (Id) then
return False;
-- Do not inline predicate functions (treated specially by GNATprove)
@@ -1481,7 +1481,7 @@ package body Inline is
pragma Assert (Msg (Msg'Last) = '?');
- -- Legacy front end inlining model
+ -- Legacy front-end inlining model
if not Back_End_Inlining then
@@ -1514,7 +1514,7 @@ package body Inline is
Error_Msg_NE (Msg & "p?", N, Subp);
end if;
- -- New semantics relying on back end inlining
+ -- New semantics relying on back-end inlining
elsif Is_Serious then
@@ -1592,15 +1592,6 @@ package body Inline is
-- body N has no local declarations and its unique statement is a single
-- extended return statement with a handled statements sequence.
- procedure Generate_Subprogram_Body
- (N : Node_Id;
- Body_To_Inline : out Node_Id);
- -- Generate a parameterless duplicate of subprogram body N. Occurrences
- -- of pragmas referencing the formals are removed since they have no
- -- meaning when the body is inlined and the formals are rewritten (the
- -- analysis of the non-inlined body will handle these pragmas properly).
- -- A new internal name is associated with Body_To_Inline.
-
procedure Split_Unconstrained_Function
(N : Node_Id;
Spec_Id : Entity_Id);
@@ -1616,6 +1607,63 @@ package body Inline is
--------------------------
procedure Build_Body_To_Inline (N : Node_Id; Spec_Id : Entity_Id) is
+
+ procedure Generate_Subprogram_Body
+ (N : Node_Id;
+ Body_To_Inline : out Node_Id);
+ -- Generate a parameterless duplicate of subprogram body N. Note that
+ -- occurrences of pragmas referencing the formals are removed since
+ -- they have no meaning when the body is inlined and the formals are
+ -- rewritten (the analysis of the non-inlined body will handle these
+ -- pragmas). A new internal name is associated with Body_To_Inline.
+
+ -----------------------------
+ -- Generate_Body_To_Inline --
+ -----------------------------
+
+ procedure Generate_Subprogram_Body
+ (N : Node_Id;
+ Body_To_Inline : out Node_Id)
+ is
+ begin
+ -- Within an instance, the body to inline must be treated as a
+ -- nested generic so that proper global references are preserved.
+
+ -- Note that we do not do this at the library level, because it
+ -- is not needed, and furthermore this causes trouble if front
+ -- end inlining is activated (-gnatN).
+
+ if In_Instance
+ and then Scope (Current_Scope) /= Standard_Standard
+ then
+ Body_To_Inline := Copy_Generic_Node (N, Empty, True);
+ else
+ Body_To_Inline := Copy_Separate_Tree (N);
+ end if;
+
+ -- Remove aspects/pragmas that have no meaning in an inlined body
+
+ Remove_Aspects_And_Pragmas (Body_To_Inline);
+
+ -- We need to capture references to the formals in order
+ -- to substitute the actuals at the point of inlining, i.e.
+ -- instantiation. To treat the formals as globals to the body to
+ -- inline, we nest it within a dummy parameterless subprogram,
+ -- declared within the real one.
+
+ Set_Parameter_Specifications
+ (Specification (Body_To_Inline), No_List);
+
+ -- A new internal name is associated with Body_To_Inline to avoid
+ -- conflicts when the non-inlined body N is analyzed.
+
+ Set_Defining_Unit_Name (Specification (Body_To_Inline),
+ Make_Defining_Identifier (Sloc (N), New_Internal_Name ('P')));
+ Set_Corresponding_Spec (Body_To_Inline, Empty);
+ end Generate_Subprogram_Body;
+
+ -- Local variables
+
Decl : constant Node_Id := Unit_Declaration_Node (Spec_Id);
Original_Body : Node_Id;
Body_To_Analyze : Node_Id;
@@ -1626,7 +1674,7 @@ package body Inline is
-- Within an instance, the body to inline must be treated as a nested
-- generic, so that the proper global references are preserved. We
-- do not do this at the library level, because it is not needed, and
- -- furthermore this causes trouble if front end inlining is activated
+ -- furthermore this causes trouble if front-end inlining is activated
-- (-gnatN).
if In_Instance
@@ -1716,51 +1764,6 @@ package body Inline is
and then Present (Handled_Statement_Sequence (Ret_Node));
end Can_Split_Unconstrained_Function;
- -----------------------------
- -- Generate_Body_To_Inline --
- -----------------------------
-
- procedure Generate_Subprogram_Body
- (N : Node_Id;
- Body_To_Inline : out Node_Id)
- is
- begin
- -- Within an instance, the body to inline must be treated as a nested
- -- generic, so that the proper global references are preserved.
-
- -- Note that we do not do this at the library level, because it
- -- is not needed, and furthermore this causes trouble if front
- -- end inlining is activated (-gnatN).
-
- if In_Instance
- and then Scope (Current_Scope) /= Standard_Standard
- then
- Body_To_Inline := Copy_Generic_Node (N, Empty, True);
- else
- Body_To_Inline := Copy_Separate_Tree (N);
- end if;
-
- -- Remove all aspects/pragmas that have no meaning in an inlined body
-
- Remove_Aspects_And_Pragmas (Body_To_Inline);
-
- -- We need to capture references to the formals in order
- -- to substitute the actuals at the point of inlining, i.e.
- -- instantiation. To treat the formals as globals to the body to
- -- inline, we nest it within a dummy parameterless subprogram,
- -- declared within the real one.
-
- Set_Parameter_Specifications
- (Specification (Body_To_Inline), No_List);
-
- -- A new internal name is associated with Body_To_Inline to avoid
- -- conflicts when the non-inlined body N is analyzed.
-
- Set_Defining_Unit_Name (Specification (Body_To_Inline),
- Make_Defining_Identifier (Sloc (N), New_Internal_Name ('P')));
- Set_Corresponding_Spec (Body_To_Inline, Empty);
- end Generate_Subprogram_Body;
-
----------------------------------
-- Split_Unconstrained_Function --
----------------------------------
@@ -1945,14 +1948,14 @@ package body Inline is
Parameter_Associations => Actual_List);
end;
- -- Generate
+ -- Generate:
-- declare
-- New_Obj : ...
-- begin
- -- main_1__F1b (New_Obj, ...);
- -- return Obj;
- -- end B10b;
+ -- Proc (New_Obj, ...);
+ -- return New_Obj;
+ -- end;
Blk_Stmt :=
Make_Block_Statement (Loc,
@@ -2922,8 +2925,8 @@ package body Inline is
-- The semantic analyzer checked that frontend-inlined functions
-- returning unconstrained types have no declarations and have
-- a single extended return statement. As part of its processing
- -- the function was split in two subprograms: a procedure P and
- -- a function F that has a block with a call to procedure P (see
+ -- the function was split in two subprograms: a procedure P' and
+ -- a function F' that has a block with a call to procedure P' (see
-- Split_Unconstrained_Function).
else
@@ -3269,7 +3272,7 @@ package body Inline is
-- avoid generating undesired extra calls and goto statements.
-- Given:
- -- function Func (...) return ...
+ -- function Func (...) return String is
-- begin
-- declare
-- Result : String (1 .. 4);
@@ -3277,7 +3280,7 @@ package body Inline is
-- Proc (Result, ...);
-- return Result;
-- end;
- -- end F;
+ -- end Func;
-- Result : String := Func (...);
@@ -3526,7 +3529,7 @@ package body Inline is
return True;
end if;
- -- Then declarations excluded only for front end inlining
+ -- Then declarations excluded only for front-end inlining
if Back_End_Inlining then
null;