From: Eric Botcazou <[email protected]>
The oversight is that the dynamic accessibility checks should be generated
neither when accessibility checks are disabled, for example by means of the
-gnatp switch, nor when the GNAT restriction No_Dynamic_Accessibility_Checks
is enabled.
gcc/ada/ChangeLog:
* accessibility.adb
(Apply_Accessibility_Check_For_Class_Wide_Return): Do not test if
accessibility checks are suppressed here but...
(Apply_Accessibility_Check_For_Return): ...here instead.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/accessibility.adb | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/gcc/ada/accessibility.adb b/gcc/ada/accessibility.adb
index 93104064eb7..396c8914f9a 100644
--- a/gcc/ada/accessibility.adb
+++ b/gcc/ada/accessibility.adb
@@ -1279,7 +1279,6 @@ package body Accessibility is
if Ada_Version >= Ada_2005
and then not CodePeer_Mode
and then Tagged_Type_Expansion
- and then not Scope_Suppress.Suppress (Accessibility_Check)
and then
(Is_Class_Wide_Type (Etype (Exp))
or else Nkind (Exp) in
@@ -1665,6 +1664,12 @@ package body Accessibility is
Typ : constant Entity_Id := Etype (Func);
begin
+ -- Return immediately if accessiblity checks are suppressed for Func
+
+ if Accessibility_Checks_Suppressed (Func) then
+ return;
+ end if;
+
-- Ada 2005 (AI95-344): If the result type is class-wide, then insert
-- a check that the level of the return expression's underlying type
-- is not deeper than the level of the master enclosing the function.
--
2.53.0