public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc(refs/users/pheeck/heads/sccp)] ada: Do not share Packed Array Type if sizes of types differ
@ 2023-02-15 10:16 Filip Kastl
  0 siblings, 0 replies; only message in thread
From: Filip Kastl @ 2023-02-15 10:16 UTC (permalink / raw)
  To: gcc-cvs

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

commit 2e202ef6d26cb1015f3c2e17e694588a1639d447
Author: Marc Poulhiès <poulhies@adacore.com>
Date:   Tue Nov 15 16:47:59 2022 +0100

    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.

Diff:
---
 gcc/ada/exp_pakd.adb | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/exp_pakd.adb b/gcc/ada/exp_pakd.adb
index d4a62ace9c2..29735c07a88 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;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-15 10:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-15 10:16 [gcc(refs/users/pheeck/heads/sccp)] ada: Do not share Packed Array Type if sizes of types differ Filip Kastl

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).