diff options
author | Tristan Gingold <tgingold@free.fr> | 2023-01-10 21:45:36 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2023-01-10 21:48:21 +0100 |
commit | d321ec7a8a3aae1463cf22d68d13ac9a1c951caf (patch) | |
tree | d86b99acb34a8a093b2cd096e6003e24c85917a3 /src/synth | |
parent | e91b804e3fd98a1103f10a0fff4460095db161ec (diff) | |
download | ghdl-d321ec7a8a3aae1463cf22d68d13ac9a1c951caf.tar.gz ghdl-d321ec7a8a3aae1463cf22d68d13ac9a1c951caf.tar.bz2 ghdl-d321ec7a8a3aae1463cf22d68d13ac9a1c951caf.zip |
synth: adjust unshare_type for unbounded composite types
Diffstat (limited to 'src/synth')
-rw-r--r-- | src/synth/elab-vhdl_objtypes.adb | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/synth/elab-vhdl_objtypes.adb b/src/synth/elab-vhdl_objtypes.adb index c00f73478..1555c90d3 100644 --- a/src/synth/elab-vhdl_objtypes.adb +++ b/src/synth/elab-vhdl_objtypes.adb @@ -1111,11 +1111,19 @@ package body Elab.Vhdl_Objtypes is is Res : Type_Acc; begin - if Typ = Base or else Typ.Is_Global = Global then + if Typ = Base then return Typ; end if; - Res := Raw_Copy (Typ, Pool); - Res.Is_Global := Global; + if Typ.Is_Global /= Global then + Res := Raw_Copy (Typ, Pool); + Res.Is_Global := Global; + elsif Global then + return Typ; + else + -- We want a local copy, but the original local type can have + -- global sub-elements. + Res := Typ; + end if; case Res.Kind is when Type_Bit @@ -1138,7 +1146,9 @@ package body Elab.Vhdl_Objtypes is | Type_Unbounded_Record => raise Internal_Error; when Type_Record => - Res.Rec := Create_Rec_El_Array (Typ.Rec.Len, Pool); + if Typ /= Res then + Res.Rec := Create_Rec_El_Array (Typ.Rec.Len, Pool); + end if; for I in Typ.Rec.E'Range loop Res.Rec.E (I) := (Offs => Typ.Rec.E (I).Offs, Typ => Unshare_Type (Typ.Rec.E (I).Typ, |