From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1285) id 550C6386194C; Wed, 27 Sep 2023 08:28:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 550C6386194C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695803337; bh=YxKixg9APzZ3+Wnf7Y9eKDOS/KWszPcPi53cvC7S+xs=; h=From:To:Subject:Date:From; b=mlkgc4FCrb30v2YgQs4U5n6OoxcYQLDbqA72FALhCqHx9rNC65oVnGTZTUCztleMa C/nfZF36EoUy8zuOr8FWbtIuDw00DfMdNQmJetQxAJUSeXStvBXh6bCiR5colVtDuh X4fLrF/2xcsgom+g5PVDeC4qHybOEQYTN5MH3UAY= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Eric Botcazou To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-7911] ada: Fix missing finalization of extended return object on abnormal completion X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/releases/gcc-13 X-Git-Oldrev: 51555893149dab8a6861d5b3c41e0ba3e2ed7372 X-Git-Newrev: 3f31cd4388c92910e66e96cc1744543d983f7f33 Message-Id: <20230927082857.550C6386194C@sourceware.org> Date: Wed, 27 Sep 2023 08:28:57 +0000 (GMT) List-Id: https://gcc.gnu.org/g:3f31cd4388c92910e66e96cc1744543d983f7f33 commit r13-7911-g3f31cd4388c92910e66e96cc1744543d983f7f33 Author: Eric Botcazou 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 a200d6334bf..e71fd617406 100644 --- a/gcc/ada/einfo.ads +++ b/gcc/ada/einfo.ads @@ -4519,11 +4519,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 c6e9ae3cfb4..01d938ec6c3 100644 --- a/gcc/ada/exp_ch6.adb +++ b/gcc/ada/exp_ch6.adb @@ -5326,7 +5326,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; @@ -5425,7 +5425,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 53261c2a1f1..757cf7318f9 100644 --- a/gcc/ada/exp_ch7.adb +++ b/gcc/ada/exp_ch7.adb @@ -2376,9 +2376,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 6ae671c43a6..fe48722cedd 100644 --- a/gcc/ada/exp_util.adb +++ b/gcc/ada/exp_util.adb @@ -12896,9 +12896,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)