]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix oversight in latest accessibility change
authorEric Botcazou <ebotcazou@adacore.com>
Thu, 19 Feb 2026 18:36:18 +0000 (19:36 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 28 May 2026 08:52:45 +0000 (10:52 +0200)
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.

gcc/ada/accessibility.adb

index 93104064eb716bc26b6e853e10d877b642909232..396c8914f9a53a4c943210b834600dddc2d4643d 100644 (file)
@@ -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.