This fixes the signature mismatch recently introduced for Defining_Entity
between the front-end proper and gigi.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* sem_util.ads (Defining_Entity): Remove Empty_On_Errors parameter.
(Defining_Entity_Or_Empty): New function.
* sem_util.adb (Defining_Entity): Move bulk of implementation to...
(Defining_Entity_Or_Empty): ...here. Do not raise Program_Error.
(Innermost_Master_Scope_Depth): Call Defining_Entity_Or_Empty.
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -269,14 +269,12 @@ package body Sem_Util is
-- Construct an integer literal representing an accessibility level
-- with its type set to Natural.
- function Innermost_Master_Scope_Depth
- (N : Node_Id) return Uint;
+ function Innermost_Master_Scope_Depth (N : Node_Id) return Uint;
-- Returns the scope depth of the given node's innermost
-- enclosing dynamic scope (effectively the accessibility
-- level of the innermost enclosing master).
- function Function_Call_Or_Allocator_Level
- (N : Node_Id) return Node_Id;
+ function Function_Call_Or_Allocator_Level (N : Node_Id) return Node_Id;
-- Centralized processing of subprogram calls which may appear in
-- prefix notation.
@@ -284,10 +282,9 @@ package body Sem_Util is
-- Innermost_Master_Scope_Depth --
----------------------------------
- function Innermost_Master_Scope_Depth
- (N : Node_Id) return Uint
- is
+ function Innermost_Master_Scope_Depth (N : Node_Id) return Uint is
Encl_Scop : Entity_Id;
+ Ent : Entity_Id;
Node_Par : Node_Id := Parent (N);
Master_Lvl_Modifier : Int := 0;
@@ -301,12 +298,10 @@ package body Sem_Util is
-- among other things. These cases are detected properly ???
while Present (Node_Par) loop
+ Ent := Defining_Entity_Or_Empty (Node_Par);
- if Present (Defining_Entity
- (Node_Par, Empty_On_Errors => True))
- then
- Encl_Scop := Nearest_Dynamic_Scope
- (Defining_Entity (Node_Par));
+ if Present (Ent) then
+ Encl_Scop := Nearest_Dynamic_Scope (Ent);
-- Ignore transient scopes made during expansion
@@ -7076,10 +7071,23 @@ package body Sem_Util is
-- Defining_Entity --
---------------------
- function Defining_Entity
- (N : Node_Id;
- Empty_On_Errors : Boolean := False) return Entity_Id
- is
+ function Defining_Entity (N : Node_Id) return Entity_Id is
+ Ent : constant Entity_Id := Defining_Entity_Or_Empty (N);
+
+ begin
+ if Present (Ent) then
+ return Ent;
+
+ else
+ raise Program_Error;
+ end if;
+ end Defining_Entity;
+
+ ------------------------------
+ -- Defining_Entity_Or_Empty --
+ ------------------------------
+
+ function Defining_Entity_Or_Empty (N : Node_Id) return Entity_Id is
begin
case Nkind (N) is
when N_Abstract_Subprogram_Declaration
@@ -7178,13 +7186,9 @@ package body Sem_Util is
return Entity (Identifier (N));
when others =>
- if Empty_On_Errors then
- return Empty;
- end if;
-
- raise Program_Error;
+ return Empty;
end case;
- end Defining_Entity;
+ end Defining_Entity_Or_Empty;
--------------------------
-- Denotes_Discriminant --
diff --git a/gcc/ada/sem_util.ads b/gcc/ada/sem_util.ads
--- a/gcc/ada/sem_util.ads
+++ b/gcc/ada/sem_util.ads
@@ -662,9 +662,7 @@ package Sem_Util is
-- in the case of a descendant of a generic formal type (returns Int'Last
-- instead of 0).
- function Defining_Entity
- (N : Node_Id;
- Empty_On_Errors : Boolean := False) return Entity_Id;
+ function Defining_Entity (N : Node_Id) return Entity_Id;
-- Given a declaration N, returns the associated defining entity. If the
-- declaration has a specification, the entity is obtained from the
-- specification. If the declaration has a defining unit name, then the
@@ -675,19 +673,13 @@ package Sem_Util is
-- local entities declared during loop expansion. These entities need
-- debugging information, generated through Qualify_Entity_Names, and
-- the loop declaration must be placed in the table Name_Qualify_Units.
- --
- -- Set flag Empty_On_Errors to change the behavior of this routine as
- -- follows:
- --
- -- * True - A declaration that lacks a defining entity returns Empty.
- -- A node that does not allow for a defining entity returns Empty.
- --
- -- * False - A declaration that lacks a defining entity is given a new
- -- internally generated entity which is subsequently returned. A node
- -- that does not allow for a defining entity raises Program_Error
-- WARNING: There is a matching C declaration of this subprogram in fe.h
+ function Defining_Entity_Or_Empty (N : Node_Id) return Entity_Id;
+ -- This is equivalent to Defining_Entity but it returns Empty for nodes
+ -- without an entity instead of raising Program_Error.
+
function Denotes_Discriminant
(N : Node_Id;
Check_Concurrent : Boolean := False) return Boolean;