https://gcc.gnu.org/g:fc12d7f9a170baf287eba265daf83ac53ff0b880

commit r17-1209-gfc12d7f9a170baf287eba265daf83ac53ff0b880
Author: Eric Botcazou <[email protected]>
Date:   Sat May 2 09:13:20 2026 +0200

    ada: Do not generate accessibility checks for specific synthesized return
    
    This is the return synthesized in a function whose body has been wrapped in
    a nested _Wrapped_Statements function, since it only propagates the result.
    
    gcc/ada/ChangeLog:
    
            * accessibility.adb (Apply_Accessibility_Check_For_Return): Bail out
            for the return synthesized in a function with _Wrapped_Statements.

Diff:
---
 gcc/ada/accessibility.adb | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gcc/ada/accessibility.adb b/gcc/ada/accessibility.adb
index 9b5d0fba73ae..52d4810987f6 100644
--- a/gcc/ada/accessibility.adb
+++ b/gcc/ada/accessibility.adb
@@ -1671,6 +1671,13 @@ package body Accessibility is
          return;
       end if;
 
+      --  No checks are needed for the return synthesized in a function whose
+      --  body has been wrapped in a nested _Wrapped_Statements function.
+
+      if Present (Wrapped_Statements (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