aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2023-12-16 11:34:48 +0100
committerMarc Poulhiès <poulhies@adacore.com>2024-05-06 11:11:28 +0200
commit3862106d3506293ad5af2fc04d2d21ef3a5e0edf (patch)
tree5e70b9d2a0176febc1be5dae4a55a2e813d456bb /gcc
parent0b591735952e006c00be23e5b64631809bd93d10 (diff)
downloadgcc-3862106d3506293ad5af2fc04d2d21ef3a5e0edf.zip
gcc-3862106d3506293ad5af2fc04d2d21ef3a5e0edf.tar.gz
gcc-3862106d3506293ad5af2fc04d2d21ef3a5e0edf.tar.bz2
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) <Finalization_Size>: Return 0 if the prefix is a dereference of an access value subject to the No_Heap_Finalization pragma.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_attr.adb10
1 files changed, 9 insertions, 1 deletions
diff --git a/gcc/ada/exp_attr.adb b/gcc/ada/exp_attr.adb
index 614f1fb..a8e06f0 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 (