public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Marc Poulhi?s <dkm@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-4272] ada: Fix missing finalization of extended return object on abnormal completion
Date: Tue, 26 Sep 2023 11:46:01 +0000 (GMT)	[thread overview]
Message-ID: <20230926114601.CB34E386189B@sourceware.org> (raw)

https://gcc.gnu.org/g:2e135bdb28d386b0cda2ee7e35338ad06136042d

commit r14-4272-g2e135bdb28d386b0cda2ee7e35338ad06136042d
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Thu Sep 14 16:42:45 2023 +0200

    ada: Fix missing finalization of extended return object on abnormal completion
    
    This happens in the case of a nonlimited return type and is a fallout of the
    optimization recently implemented for them.
    
    gcc/ada/
    
            * einfo.ads (Status_Flag_Or_Transient_Decl): Remove ??? comment.
            * exp_ch6.adb (Expand_N_Extended_Return_Statement): Extend the
            handling of finalizable return objects to the non-BIP case.
            * exp_ch7.adb (Build_Finalizer.Process_Declarations): Adjust the
            comment accordingly.
            * exp_util.adb (Requires_Cleanup_Actions): Likewise.

Diff:
---
 gcc/ada/einfo.ads    | 8 ++++----
 gcc/ada/exp_ch6.adb  | 4 ++--
 gcc/ada/exp_ch7.adb  | 6 +++---
 gcc/ada/exp_util.adb | 6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/gcc/ada/einfo.ads b/gcc/ada/einfo.ads
index 977392899f9..9165fb7485d 100644
--- a/gcc/ada/einfo.ads
+++ b/gcc/ada/einfo.ads
@@ -4518,11 +4518,11 @@ package Einfo is
 --    Status_Flag_Or_Transient_Decl
 --       Defined in constant, loop, and variable entities. Applies to objects
 --       that require special treatment by the finalization machinery, such as
---       extended return results, IF and CASE expression results, and objects
+--       extended return objects, conditional expression results, and objects
 --       inside N_Expression_With_Actions nodes. The attribute contains the
---       entity of a flag which specifies particular behavior over a region of
---       code or the declaration of a "hook" object.
---       In which case is it a flag, or a hook object???
+--       entity of a flag which specifies a particular behavior over a region
+--       of the extended return for the return objects, or the declaration of a
+--       hook object for conditional expressions and N_Expression_With_Actions.
 
 --    Storage_Size_Variable [implementation base type only]
 --       Defined in access types and task type entities. This flag is set
diff --git a/gcc/ada/exp_ch6.adb b/gcc/ada/exp_ch6.adb
index a16dfe2d57e..beb2e2f90f0 100644
--- a/gcc/ada/exp_ch6.adb
+++ b/gcc/ada/exp_ch6.adb
@@ -5607,7 +5607,7 @@ package body Exp_Ch6 is
       --  with the scope finalizer. There is one flag per each return object
       --  in case of multiple returns.
 
-      if Is_BIP_Func and then Needs_Finalization (Etype (Ret_Obj_Id)) then
+      if Needs_Finalization (Etype (Ret_Obj_Id)) then
          declare
             Flag_Decl : Node_Id;
             Flag_Id   : Entity_Id;
@@ -5706,7 +5706,7 @@ package body Exp_Ch6 is
          --  Update the state of the function right before the object is
          --  returned.
 
-         if Is_BIP_Func and then Needs_Finalization (Etype (Ret_Obj_Id)) then
+         if Needs_Finalization (Etype (Ret_Obj_Id)) then
             declare
                Flag_Id : constant Entity_Id :=
                            Status_Flag_Or_Transient_Decl (Ret_Obj_Id);
diff --git a/gcc/ada/exp_ch7.adb b/gcc/ada/exp_ch7.adb
index 4ea5e6ede64..271dfd22618 100644
--- a/gcc/ada/exp_ch7.adb
+++ b/gcc/ada/exp_ch7.adb
@@ -2381,9 +2381,9 @@ package body Exp_Ch7 is
                elsif Is_Ignored_Ghost_Entity (Obj_Id) then
                   null;
 
-               --  Return object of a build-in-place function. This case is
-               --  recognized and marked by the expansion of an extended return
-               --  statement (see Expand_N_Extended_Return_Statement).
+               --  Return object of extended return statements. This case is
+               --  recognized and marked by the expansion of extended return
+               --  statements (see Expand_N_Extended_Return_Statement).
 
                elsif Needs_Finalization (Obj_Typ)
                  and then Is_Return_Object (Obj_Id)
diff --git a/gcc/ada/exp_util.adb b/gcc/ada/exp_util.adb
index 2e6a1cf892e..9ac64fe9381 100644
--- a/gcc/ada/exp_util.adb
+++ b/gcc/ada/exp_util.adb
@@ -13127,9 +13127,9 @@ package body Exp_Util is
             elsif Is_Ignored_Ghost_Entity (Obj_Id) then
                null;
 
-            --  Return object of a build-in-place function. This case is
-            --  recognized and marked by the expansion of an extended return
-            --  statement (see Expand_N_Extended_Return_Statement).
+            --  Return object of extended return statements. This case is
+            --  recognized and marked by the expansion of extended return
+            --  statements (see Expand_N_Extended_Return_Statement).
 
             elsif Needs_Finalization (Obj_Typ)
               and then Is_Return_Object (Obj_Id)

                 reply	other threads:[~2023-09-26 11:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230926114601.CB34E386189B@sourceware.org \
    --to=dkm@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).