From: Arnaud Charlet Date: Mon, 24 May 2021 12:38:20 +0000 (-0400) Subject: [Ada] Revert meaning of -gnatd_b X-Git-Tag: basepoints/gcc-13~6170 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a2f91a52b4b989b52f0ccdabc2d9aead05c8056b;p=thirdparty%2Fgcc.git [Ada] Revert meaning of -gnatd_b gcc/ada/ * debug.adb, sem_util.adb: Revert meaning of -gnatd_b. * sem_res.adb: Minor reformatting. --- diff --git a/gcc/ada/debug.adb b/gcc/ada/debug.adb index 5a4d1d3cdaaf..599c9c958e1f 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 5791d3d99370..26e4a07ae31d 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 12e5aa897759..ba8402913454 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.