diff options
author | Justin Squirek <squirek@adacore.com> | 2021-06-29 18:38:09 -0400 |
---|---|---|
committer | Pierre-Marie de Rodat <derodat@adacore.com> | 2021-10-04 08:45:13 +0000 |
commit | 5e0367dd64f4946d76477a8545d7abf3c0802806 (patch) | |
tree | 0be6ee1aab23b667ba995e983485136ecb48f117 /gcc/ada/sem_attr.adb | |
parent | 29ca68773b8bbb89b6e0cbb21d55d0ceeec58f9c (diff) | |
download | gcc-5e0367dd64f4946d76477a8545d7abf3c0802806.zip gcc-5e0367dd64f4946d76477a8545d7abf3c0802806.tar.gz gcc-5e0367dd64f4946d76477a8545d7abf3c0802806.tar.bz2 |
[Ada] Incremental patch for restriction No_Dynamic_Accessibility_Checks
gcc/ada/
* doc/gnat_rm/standard_and_implementation_defined_restrictions.rst:
Add new entry for No_Dynamic_Accessibility_Checks documenting
behavior.
* gnat_rm.texi: Regenerate.
* exp_ch4.adb (Expand_N_In): Perform special expansion for
membership tests when No_Dynamic_Accessibility_Checks is active.
* sem_attr.adb (Resolve_Attribute): Skip static accessibility
check on actuals for anonymous access type formal parameters,
and add constants for readability.
* sem_util.adb (Function_Call_Or_Allocator_Level): Use the
innermost master for determining the level for function calls
within the alternative accessibility model.
(Type_Access_Level): Properly get the level for anonymous access
function result types.
Diffstat (limited to 'gcc/ada/sem_attr.adb')
-rw-r--r-- | gcc/ada/sem_attr.adb | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/gcc/ada/sem_attr.adb b/gcc/ada/sem_attr.adb index 180210c..4d69d58 100644 --- a/gcc/ada/sem_attr.adb +++ b/gcc/ada/sem_attr.adb @@ -11506,28 +11506,45 @@ package body Sem_Attr is -- in such a context - unless the restriction -- No_Dynamic_Accessibility_Checks is active. - if Attr_Id /= Attribute_Unchecked_Access - and then - (Ekind (Btyp) = E_General_Access_Type - or else No_Dynamic_Accessibility_Checks_Enabled (Btyp)) - - -- Call Accessibility_Level directly to avoid returning zero - -- on cases where the prefix is an explicitly aliased - -- parameter in a return statement, instead of using the - -- normal Static_Accessibility_Level function. - - -- Shouldn't this be handled somehow in - -- Static_Accessibility_Level ??? + declare + No_Dynamic_Acc_Checks : constant Boolean := + No_Dynamic_Accessibility_Checks_Enabled (Btyp); - and then Nkind (Accessibility_Level (P, Dynamic_Level)) - = N_Integer_Literal - and then - Intval (Accessibility_Level (P, Dynamic_Level)) - > Deepest_Type_Access_Level (Btyp) - then - Accessibility_Message; - return; - end if; + Compatible_Alt_Checks : constant Boolean := + No_Dynamic_Acc_Checks and then not Debug_Flag_Underscore_B; + begin + if Attr_Id /= Attribute_Unchecked_Access + and then (Ekind (Btyp) = E_General_Access_Type + or else No_Dynamic_Acc_Checks) + + -- In the case of the alternate "compatibility" + -- accessibility model we do not perform a static + -- accessibility check on actuals for anonymous access + -- types - so exclude them here. + + and then not (Compatible_Alt_Checks + and then Is_Actual_Parameter (N) + and then Ekind (Btyp) + = E_Anonymous_Access_Type) + + -- Call Accessibility_Level directly to avoid returning + -- zero on cases where the prefix is an explicitly aliased + -- parameter in a return statement, instead of using the + -- normal Static_Accessibility_Level function. + + -- Shouldn't this be handled somehow in + -- Static_Accessibility_Level ??? + + and then Nkind (Accessibility_Level (P, Dynamic_Level)) + = N_Integer_Literal + and then + Intval (Accessibility_Level (P, Dynamic_Level)) + > Deepest_Type_Access_Level (Btyp) + then + Accessibility_Message; + return; + end if; + end; end if; if Ekind (Btyp) in E_Access_Protected_Subprogram_Type |