https://gcc.gnu.org/g:693227c871f305b8c228eef14819b141bd907807

commit r17-860-g693227c871f305b8c228eef14819b141bd907807
Author: Eric Botcazou <[email protected]>
Date:   Thu Feb 19 19:36:18 2026 +0100

    ada: Fix oversight in latest accessibility change
    
    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.

Diff:
---
 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 93104064eb71..396c8914f9a5 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.

Reply via email to