aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarc Poulhiès <poulhies@adacore.com>2022-11-15 16:47:59 +0100
committerMarc Poulhiès <poulhies@adacore.com>2022-11-21 11:10:34 +0100
commita186dd158decad693bd18c95962a9ea61022166c (patch)
treea83a6beea57a57edd33966496ab0ead1af20ebfb /gcc
parent6f089469f4f0960818498ca5ad2bd3797a4b1d43 (diff)
downloadgcc-a186dd158decad693bd18c95962a9ea61022166c.zip
gcc-a186dd158decad693bd18c95962a9ea61022166c.tar.gz
gcc-a186dd158decad693bd18c95962a9ea61022166c.tar.bz2
ada: Do not share Packed Array Type if sizes of types differ
If a subtype has a Size attribute value different than the size of its ancestor, then the Packed Array Type can't be shared and a new one must be created. gcc/ada/ * exp_pakd.adb (Create_Packed_Array_Impl_Type): Do not share PAT if sizes of types differ.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/exp_pakd.adb13
1 files changed, 8 insertions, 5 deletions
diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb
index d4a62ac..29735c0 100644
--- a/gcc/ada/exp_pakd.adb
+++ b/gcc/ada/exp_pakd.adb
@@ -671,11 +671,11 @@ package body Exp_Pakd is
return;
end if;
- -- If our immediate ancestor subtype is constrained, and it already
- -- has a packed array type, then just share the same type, since the
- -- bounds must be the same. If the ancestor is not an array type but
- -- a private type, as can happen with multiple instantiations, create
- -- a new packed type, to avoid privacy issues.
+ -- If our immediate ancestor subtype is constrained, and it already has
+ -- a packed array type, and it has the same size, then just share the
+ -- same type, since the bounds must be the same. If the ancestor is not
+ -- an array type but a private type, as can happen with multiple
+ -- instantiations, create a new packed type, to avoid privacy issues.
if Ekind (Typ) = E_Array_Subtype then
Ancest := Ancestor_Subtype (Typ);
@@ -684,6 +684,9 @@ package body Exp_Pakd is
and then Is_Array_Type (Ancest)
and then Is_Constrained (Ancest)
and then Present (Packed_Array_Impl_Type (Ancest))
+ and then Known_Esize (Typ)
+ and then Known_Esize (Ancest)
+ and then Esize (Typ) = Esize (Ancest)
then
Set_Packed_Array_Impl_Type (Typ, Packed_Array_Impl_Type (Ancest));
return;