public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2143] [Ada] Revert meaning of -gnatd_b
@ 2021-07-08 13:36 Pierre-Marie de Rodat
  0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-07-08 13:36 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:a2f91a52b4b989b52f0ccdabc2d9aead05c8056b

commit r12-2143-ga2f91a52b4b989b52f0ccdabc2d9aead05c8056b
Author: Arnaud Charlet <charlet@adacore.com>
Date:   Mon May 24 08:38:20 2021 -0400

    [Ada] Revert meaning of -gnatd_b
    
    gcc/ada/
    
            * debug.adb, sem_util.adb: Revert meaning of -gnatd_b.
            * sem_res.adb: Minor reformatting.

Diff:
---
 gcc/ada/debug.adb    |  6 +++++-
 gcc/ada/sem_res.adb  |  3 +--
 gcc/ada/sem_util.adb | 56 ++++++++++++++++++++++++++--------------------------
 3 files changed, 34 insertions(+), 31 deletions(-)

diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb
index 5a4d1d3cdaa..599c9c958e1 100644
--- a/gcc/ada/debug.adb
+++ b/gcc/ada/debug.adb
@@ -140,7 +140,7 @@ package body Debug is
    --  d.Z  Do not enable expansion in configurable run-time mode
 
    --  d_a  Stop elaboration checks on accept or select statement
-   --  d_b  Use compatibility model under No_Dynamic_Accessibility_Checks
+   --  d_b  Use designated type model under No_Dynamic_Accessibility_Checks
    --  d_c  CUDA compilation : compile for the host
    --  d_d
    --  d_e  Ignore entry calls and requeue statements for elaboration
@@ -956,6 +956,10 @@ package body Debug is
    --       behavior is similar to that of No_Entry_Calls_In_Elaboration_Code,
    --       but does not penalize actual entry calls in elaboration code.
 
+   --  d_b  When the restriction No_Dynamic_Accessibility_Checks is enabled,
+   --       use the simple "designated type" accessibility model, instead of
+   --       using the implicit level of the anonymous access type declaration.
+
    --  d_e  The compiler ignores simple entry calls, asynchronous transfer of
    --       control, conditional entry calls, timed entry calls, and requeue
    --       statements in both the static and dynamic elaboration models.
diff --git a/gcc/ada/sem_res.adb b/gcc/ada/sem_res.adb
index 5791d3d9937..26e4a07ae31 100644
--- a/gcc/ada/sem_res.adb
+++ b/gcc/ada/sem_res.adb
@@ -13738,8 +13738,7 @@ package body Sem_Res is
                     Deepest_Type_Access_Level (Target_Type)
               and then (Nkind (Associated_Node_For_Itype (Opnd_Type)) /=
                          N_Function_Specification
-                        or else Ekind (Target_Type) in
-                                  Anonymous_Access_Kind)
+                        or else Ekind (Target_Type) in Anonymous_Access_Kind)
 
               --  Check we are not in a return value ???
 
diff --git a/gcc/ada/sem_util.adb b/gcc/ada/sem_util.adb
index 12e5aa89775..ba840291345 100644
--- a/gcc/ada/sem_util.adb
+++ b/gcc/ada/sem_util.adb
@@ -410,17 +410,18 @@ package body Sem_Util is
               and then No_Dynamic_Accessibility_Checks_Enabled (N)
               and then Is_Anonymous_Access_Type (Etype (N))
             then
-               --  In the alternative model the level is that of the subprogram
+               --  In the alternative model the level is that of the
+               --  designated type.
 
                if Debug_Flag_Underscore_B then
+                  return Make_Level_Literal (Typ_Access_Level (Etype (N)));
+
+               --  Otherwise the level is that of the subprogram
+
+               else
                   return Make_Level_Literal
                            (Subprogram_Access_Level (Current_Subprogram));
                end if;
-
-               --  Otherwise the level is that of the designated type
-
-               return Make_Level_Literal
-                        (Typ_Access_Level (Etype (N)));
             end if;
 
             if Nkind (N) = N_Function_Call then
@@ -659,24 +660,22 @@ package body Sem_Util is
                if Allow_Alt_Model
                  and then No_Dynamic_Accessibility_Checks_Enabled (E)
                then
-                  --  In the alternative model the level depends on the
-                  --  entity's context.
+                  --  In the alternative model the level is that of the
+                  --  designated type entity's context.
 
                   if Debug_Flag_Underscore_B then
-                     if Is_Formal (E) then
-                        return Make_Level_Literal
-                                 (Subprogram_Access_Level
-                                   (Enclosing_Subprogram (E)));
-                     end if;
+                     return Make_Level_Literal (Typ_Access_Level (Etype (E)));
+
+                  --  Otherwise the level depends on the entity's context
 
+                  elsif Is_Formal (E) then
+                     return Make_Level_Literal
+                              (Subprogram_Access_Level
+                                (Enclosing_Subprogram (E)));
+                  else
                      return Make_Level_Literal
                               (Scope_Depth (Enclosing_Dynamic_Scope (E)));
                   end if;
-
-                  --  Otherwise the level is that of the designated type
-
-                  return Make_Level_Literal
-                           (Typ_Access_Level (Etype (E)));
                end if;
 
                --  Return the dynamic level in the normal case
@@ -701,10 +700,11 @@ package body Sem_Util is
 
             elsif Is_Type (E) then
                --  When restriction No_Dynamic_Accessibility_Checks is active
+               --  along with -gnatd_b.
 
                if Allow_Alt_Model
                  and then No_Dynamic_Accessibility_Checks_Enabled (E)
-                 and then not Debug_Flag_Underscore_B
+                 and then Debug_Flag_Underscore_B
                then
                   return Make_Level_Literal (Typ_Access_Level (E));
                end if;
@@ -799,11 +799,11 @@ package body Sem_Util is
                                         = E_Discriminant)
             then
                --  When restriction No_Dynamic_Accessibility_Checks is active
-               --  the level is that of the designated type.
+               --  and -gnatd_b set, the level is that of the designated type.
 
                if Allow_Alt_Model
                  and then No_Dynamic_Accessibility_Checks_Enabled (E)
-                 and then not Debug_Flag_Underscore_B
+                 and then Debug_Flag_Underscore_B
                then
                   return Make_Level_Literal
                            (Typ_Access_Level (Etype (E)));
@@ -825,11 +825,11 @@ package body Sem_Util is
                          = E_Anonymous_Access_Type
             then
                --  When restriction No_Dynamic_Accessibility_Checks is active
-               --  the level is that of the designated type.
+               --  and -gnatd_b set, the level is that of the designated type.
 
                if Allow_Alt_Model
                  and then No_Dynamic_Accessibility_Checks_Enabled (E)
-                 and then not Debug_Flag_Underscore_B
+                 and then Debug_Flag_Underscore_B
                then
                   return Make_Level_Literal
                            (Typ_Access_Level (Etype (E)));
@@ -7212,7 +7212,7 @@ package body Sem_Util is
 
          if Allow_Alt_Model
            and then No_Dynamic_Accessibility_Checks_Enabled (Typ)
-           and then Debug_Flag_Underscore_B
+           and then not Debug_Flag_Underscore_B
          then
             return Type_Access_Level (Typ, Allow_Alt_Model);
          end if;
@@ -29176,16 +29176,16 @@ package body Sem_Util is
             if Allow_Alt_Model
               and then No_Dynamic_Accessibility_Checks_Enabled (Btyp)
             then
-               --  In the normal model, the level of an anonymous access
+               --  In the -gnatd_b model, the level of an anonymous access
                --  type is always that of the designated type.
 
-               if not Debug_Flag_Underscore_B then
+               if Debug_Flag_Underscore_B then
                   return Type_Access_Level
                            (Designated_Type (Btyp), Allow_Alt_Model);
                end if;
 
-               --  Otherwise the secondary model dictates special handling
-               --  depending on the context of the anonymous access type.
+               --  Otherwise take the context of the anonymous access type into
+               --  account.
 
                --  Obtain the defining entity for the internally generated
                --  anonymous access type.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-07-08 13:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-08 13:36 [gcc r12-2143] [Ada] Revert meaning of -gnatd_b Pierre-Marie de Rodat

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).