aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/inline.adb
diff options
context:
space:
mode:
authorArnaud Charlet <charlet@gcc.gnu.org>2014-08-04 12:10:23 +0200
committerArnaud Charlet <charlet@gcc.gnu.org>2014-08-04 12:10:23 +0200
commit1e3689bd20d682d6f10373abccea6445d901c499 (patch)
treeb4be9bc9da828ac384e6c02e31a9563d3e2d742f /gcc/ada/inline.adb
parentaa4997841cb29b30253449c8efc85446072b5a53 (diff)
downloadgcc-1e3689bd20d682d6f10373abccea6445d901c499.zip
gcc-1e3689bd20d682d6f10373abccea6445d901c499.tar.gz
gcc-1e3689bd20d682d6f10373abccea6445d901c499.tar.bz2
[multiple changes]
2014-08-04 Arnaud Charlet <charlet@adacore.com> * sem_scil.ads: Improve comments. * sem_ch4.adb (Analyze_Equality_Op): Add support for Allow_Integer_Address (equality between Address and Integer). 2014-08-04 Yannick Moy <moy@adacore.com> * a-cfhama.adb, a-cforse.adb: Minor fixes to avoid using prefix notation on untagged objects. * sem.ads: Update comment. * inline.adb (Can_Be_Inlined_In_GNATprove_Mode): Do not inline subprograms declared in the visible part of a package. From-SVN: r213560
Diffstat (limited to 'gcc/ada/inline.adb')
-rw-r--r--gcc/ada/inline.adb67
1 files changed, 23 insertions, 44 deletions
diff --git a/gcc/ada/inline.adb b/gcc/ada/inline.adb
index 380fa25..7a3b2a7 100644
--- a/gcc/ada/inline.adb
+++ b/gcc/ada/inline.adb
@@ -1382,11 +1382,9 @@ package body Inline is
-- Returns True if subprogram Id has any contract (Pre, Post, Global,
-- Depends, etc.)
- function In_Some_Private_Part (N : Node_Id) return Boolean;
- -- Returns True if node N is defined in the private part of a package
-
- function In_Unit_Body (N : Node_Id) return Boolean;
- -- Returns True if node N is defined in the body of a unit
+ function In_Package_Visible_Spec (Id : Node_Id) return Boolean;
+ -- Returns True if subprogram Id is defined in the visible part of a
+ -- package specification.
function Is_Expression_Function (Id : Entity_Id) return Boolean;
-- Returns True if subprogram Id was defined originally as an expression
@@ -1405,51 +1403,36 @@ package body Inline is
Present (Classifications (Items)));
end Has_Some_Contract;
- --------------------------
- -- In_Some_Private_Part --
- --------------------------
+ -----------------------------
+ -- In_Package_Visible_Spec --
+ -----------------------------
- function In_Some_Private_Part (N : Node_Id) return Boolean is
- P : Node_Id;
- PP : Node_Id;
+ function In_Package_Visible_Spec (Id : Node_Id) return Boolean is
+ Decl : Node_Id := Parent (Parent (Id));
+ P : Node_Id;
begin
- P := N;
- while Present (P) and then Present (Parent (P)) loop
- PP := Parent (P);
-
- if Nkind (PP) = N_Package_Specification
- and then List_Containing (P) = Private_Declarations (PP)
- then
- return True;
- end if;
-
- P := PP;
- end loop;
-
- return False;
- end In_Some_Private_Part;
+ if Nkind (Parent (Id)) = N_Defining_Program_Unit_Name then
+ Decl := Parent (Decl);
+ end if;
- ------------------
- -- In_Unit_Body --
- ------------------
+ P := Parent (Decl);
- function In_Unit_Body (N : Node_Id) return Boolean is
- CU : constant Node_Id := Enclosing_Comp_Unit_Node (N);
- begin
- return Present (CU)
- and then Nkind_In (Unit (CU), N_Package_Body,
- N_Subprogram_Body,
- N_Subunit);
- end In_Unit_Body;
+ return Nkind (P) = N_Package_Specification
+ and then List_Containing (Decl) = Visible_Declarations (P);
+ end In_Package_Visible_Spec;
----------------------------
-- Is_Expression_Function --
----------------------------
function Is_Expression_Function (Id : Entity_Id) return Boolean is
- Decl : constant Node_Id := Parent (Parent (Id));
+ Decl : Node_Id := Parent (Parent (Id));
begin
+ if Nkind (Parent (Id)) = N_Defining_Program_Unit_Name then
+ Decl := Parent (Decl);
+ end if;
+
return Nkind (Original_Node (Decl)) = N_Expression_Function;
end Is_Expression_Function;
@@ -1482,13 +1465,9 @@ package body Inline is
if Nkind (Parent (Id)) = N_Defining_Program_Unit_Name then
return False;
- -- Do not inline subprograms declared in the visible part of a library
- -- package.
+ -- Do not inline subprograms declared in the visible part of a package
- elsif Is_Library_Level_Entity (Id)
- and then not In_Unit_Body (Id)
- and then not In_Some_Private_Part (Id)
- then
+ elsif In_Package_Visible_Spec (Id) then
return False;
-- Do not inline subprograms that have a contract on the spec or the