[Ada] Entities in E_Loop scopes are not library-level entities
authorJavier Miranda <miranda@adacore.com>
Thu, 26 Aug 2021 17:40:14 +0000 (13:40 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Mon, 4 Oct 2021 08:45:04 +0000 (08:45 +0000)
gcc/ada/

* sem_util.adb (Is_Library_Level_Entity): Return False for
entities defined in E_Loop scopes. This change is not required
by the frontend; it is required by tools that depend on the
frontend sources.
* einfo-utils.adb (Is_Dynamic_Scope): Code cleanup.

gcc/ada/einfo-utils.adb
gcc/ada/sem_util.adb

index c6c3277..38cfe34 100644 (file)
@@ -1425,26 +1425,19 @@ package body Einfo.Utils is
 
    function Is_Dynamic_Scope (Id : E) return B is
    begin
-      return
-        Ekind (Id) = E_Block
-          or else
-        Ekind (Id) = E_Function
-          or else
-        Ekind (Id) = E_Procedure
-          or else
-        Ekind (Id) = E_Subprogram_Body
-          or else
-        Ekind (Id) = E_Task_Type
-          or else
-       (Ekind (Id) = E_Limited_Private_Type
-         and then Present (Full_View (Id))
-         and then Ekind (Full_View (Id)) = E_Task_Type)
-          or else
-        Ekind (Id) = E_Entry
-          or else
-        Ekind (Id) = E_Entry_Family
+      return Ekind (Id) in E_Block
+      --  Including an E_Block that came from an N_Expression_With_Actions
+                         | E_Entry
+                         | E_Entry_Family
+                         | E_Function
+                         | E_Procedure
+                         | E_Return_Statement
+                         | E_Subprogram_Body
+                         | E_Task_Type
           or else
-        Ekind (Id) = E_Return_Statement;
+        (Ekind (Id) = E_Limited_Private_Type
+          and then Present (Full_View (Id))
+          and then Ekind (Full_View (Id)) = E_Task_Type);
    end Is_Dynamic_Scope;
 
    --------------------
index ba0341e..e206e2f 100644 (file)
@@ -18107,6 +18107,19 @@ package body Sem_Util is
 
       if Is_Formal (E) then
          return False;
+
+      --  If we somehow got an empty value for Scope, the tree must be
+      --  malformed. Rather than blow up we return True in this case.
+
+      elsif No (Scope (E)) then
+         return True;
+
+      --  Handle loops since Enclosing_Dynamic_Scope skips them; required to
+      --  properly handle entities local to quantified expressions in library
+      --  level specifications.
+
+      elsif Ekind (Scope (E)) = E_Loop then
+         return False;
       end if;
 
       --  Normal test is simply that the enclosing dynamic scope is Standard