From: Eric Botcazou <[email protected]>

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.

Tested on x86_64-pc-linux-gnu, committed on master.

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

diff --git a/gcc/ada/accessibility.adb b/gcc/ada/accessibility.adb
index 9b5d0fba73a..52d4810987f 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.
-- 
2.53.0

Reply via email to