]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Spurious dynamic accessibility check on allocator
authorJustin Squirek <squirek@adacore.com>
Fri, 9 Jul 2021 00:33:05 +0000 (20:33 -0400)
committerPierre-Marie de Rodat <derodat@adacore.com>
Tue, 21 Sep 2021 15:25:03 +0000 (15:25 +0000)
gcc/ada/

* sem_util.adb (Accessibility_Level): Remove spurious special
case for protected type components.
* exp_ch4.adb (Generate_Accessibility_Check): Use general
Accessibility_Level instead of the low-level function
Type_Access_Level.

gcc/ada/exp_ch4.adb
gcc/ada/sem_util.adb

index cf9899d76c800fa6fdb5ff6ddabb4c11f6af9bc8..497a52ba05dd5ecb5fb312997fe1a5b8e360b6e1 100644 (file)
@@ -767,8 +767,7 @@ package body Exp_Ch4 is
             Cond :=
               Make_Op_Gt (Loc,
                 Left_Opnd  => Cond,
-                Right_Opnd =>
-                  Make_Integer_Literal (Loc, Type_Access_Level (PtrT)));
+                Right_Opnd => Accessibility_Level (N, Dynamic_Level));
 
             --  Due to the complexity and side effects of the check, utilize an
             --  if statement instead of the regular Program_Error circuitry.
index 5fd72667e99d6a16bbe6ee01e7f3adeed23e76ba..45a338a927be972989b0050b81b6da0301096154 100644 (file)
@@ -728,17 +728,6 @@ package body Sem_Util is
                return Make_Level_Literal
                         (Typ_Access_Level (Etype (E)));
 
-            --  When E is a component of the current instance of a
-            --  protected type, we assume the level to be deeper than that of
-            --  the type itself.
-
-            elsif not Is_Overloadable (E)
-              and then Ekind (Scope (E)) = E_Protected_Type
-              and then Comes_From_Source (Scope (E))
-            then
-               return Make_Level_Literal
-                        (Scope_Depth (Enclosing_Dynamic_Scope (E)) + 1);
-
             --  Check if E is an expansion-generated renaming of an iterator
             --  by examining Related_Expression. If so, determine the
             --  accessibility level based on the original expression.