From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 7871) id 9F65E3858C78; Mon, 6 May 2024 09:16:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9F65E3858C78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1714987002; bh=Nk57xyfUjX+oW8rW4qMeAVNEowqdMY9ZdiYAYOiB5mE=; h=From:To:Subject:Date:From; b=pr2lB5kxG87EZ/NAV9fcGcToZB6iuQeN2RuN5E+kJmuQ/U/KQhRU8n7rzmcm4Vyim Nby41OOxxmPXvnbCWBsnt6zMo1OMNWYxVdpY5lVVWYMx4B/dUHPkJIZcNtc938Dxt/ sJo9+gzl26Xn1/cugUQ9HscnlvR2ZDmLKY3t/F/o= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Marc Poulhi?s To: gcc-cvs@gcc.gnu.org Subject: [gcc r15-185] ada: Fix wrong Finalization_Size for No_Heap_Finalization objects X-Act-Checkin: gcc X-Git-Author: Eric Botcazou X-Git-Refname: refs/heads/master X-Git-Oldrev: 0b591735952e006c00be23e5b64631809bd93d10 X-Git-Newrev: 3862106d3506293ad5af2fc04d2d21ef3a5e0edf Message-Id: <20240506091642.9F65E3858C78@sourceware.org> Date: Mon, 6 May 2024 09:16:42 +0000 (GMT) List-Id: https://gcc.gnu.org/g:3862106d3506293ad5af2fc04d2d21ef3a5e0edf commit r15-185-g3862106d3506293ad5af2fc04d2d21ef3a5e0edf Author: Eric Botcazou Date: Sat Dec 16 11:34:48 2023 +0100 ada: Fix wrong Finalization_Size for No_Heap_Finalization objects When an access type is subject to the No_Heap_Finalization pragma, no header is added in front of objects allocated through it, and the value returned by Finalization_Size is defined to be the size of this header. gcc/ada/ * exp_attr.adb (Expand_N_Attribute_Reference) : Return 0 if the prefix is a dereference of an access value subject to the No_Heap_Finalization pragma. Diff: --- gcc/ada/exp_attr.adb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb index 614f1fbe14d..a8e06f0005e 100644 --- a/gcc/ada/exp_attr.adb +++ b/gcc/ada/exp_attr.adb @@ -3563,6 +3563,14 @@ package body Exp_Attr is -- Start of processing for Finalization_Size begin + -- If the prefix is the dereference of an access value subject to + -- pragma No_Heap_Finalization, then no header has been added. + + if Nkind (Pref) = N_Explicit_Dereference + and then No_Heap_Finalization (Etype (Prefix (Pref))) + then + Rewrite (N, Make_Integer_Literal (Loc, 0)); + -- An object of a class-wide type first requires a runtime check to -- determine whether it is actually controlled or not. Depending on -- the outcome of this check, the Finalization_Size of the object @@ -3578,7 +3586,7 @@ package body Exp_Attr is -- -- and the attribute reference is replaced with a reference to Size. - if Is_Class_Wide_Type (Ptyp) then + elsif Is_Class_Wide_Type (Ptyp) then Size := Make_Temporary (Loc, 'S'); Insert_Actions (N, New_List (