From a4e0f0d85f3cada259499ab9315981eb3dae0b18 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Fri, 12 Aug 2022 06:00:54 +0200 Subject: trans-chap3: fix invalid copy of element layout. For #2166 Build element layout of a subtype if the element was defined by the subtype. --- src/vhdl/translate/trans-chap3.adb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/vhdl/translate/trans-chap3.adb') diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb index 627ae2532..12784d897 100644 --- a/src/vhdl/translate/trans-chap3.adb +++ b/src/vhdl/translate/trans-chap3.adb @@ -752,8 +752,10 @@ package body Trans.Chap3 is -- Fully unconstrained, so there is no layout variable -- for it. null; - elsif Get_Array_Element_Constraint (Def) = Null_Iir then - -- No new constraints. + elsif El_Tinfo.S.Subtype_Owner /= Tinfo then + -- The element is not owned by this subtype, so it has + -- its own layout variable that must have been set. + -- Just copy the layout. Gen_Memcpy (M2Addr (Array_Bounds_To_Element_Layout (Targ, Def)), M2Addr (Get_Composite_Type_Layout (El_Tinfo)), -- cgit v1.2.3