From 89f81ef02c4fb9d0441a2b1c773c8e9da79cda5a Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Mon, 27 Jul 2020 18:54:12 +0200 Subject: translate: fix foreach_non_composite for arrays with unbounded elements. --- src/vhdl/translate/trans-chap3.adb | 9 +++++---- src/vhdl/translate/trans-chap3.ads | 2 ++ src/vhdl/translate/trans-helpers2.adb | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb index b88881ed3..861ba894a 100644 --- a/src/vhdl/translate/trans-chap3.adb +++ b/src/vhdl/translate/trans-chap3.adb @@ -2726,11 +2726,11 @@ package body Trans.Chap3 is return Layout_To_Bounds (Array_Bounds_To_Element_Layout (B, Arr_Type)); end Array_Bounds_To_Element_Bounds; - function Array_Bounds_To_Element_Size (B : Mnode; Arr_Type : Iir) - return O_Lnode is + function Array_Bounds_To_Element_Size + (B : Mnode; Arr_Type : Iir; Mode : Object_Kind_Type) return O_Lnode is begin return Layout_To_Size - (Array_Bounds_To_Element_Layout (B, Arr_Type), Get_Object_Kind (B)); + (Array_Bounds_To_Element_Layout (B, Arr_Type), Mode); end Array_Bounds_To_Element_Size; function Type_To_Range (Atype : Iir) return Mnode @@ -3039,7 +3039,8 @@ package body Trans.Chap3 is (ON_Mul_Ov, Index, New_Value (Array_Bounds_To_Element_Size - (Get_Composite_Bounds (Arr), Atype))), + (Get_Composite_Bounds (Arr), Atype, + Get_Object_Kind (Arr)))), El_Tinfo.B.Base_Ptr_Type (Kind)), El_Tinfo, Kind, El_Tinfo.B.Base_Type (Kind), diff --git a/src/vhdl/translate/trans-chap3.ads b/src/vhdl/translate/trans-chap3.ads index bf524d43c..e9375fcf8 100644 --- a/src/vhdl/translate/trans-chap3.ads +++ b/src/vhdl/translate/trans-chap3.ads @@ -131,6 +131,8 @@ package Trans.Chap3 is -- set the bounds of it (from ARR), and return it. -- Otherwise, return a null mnode. -- Used to build a var for a subelement of ARR. + -- This is used by foreach_non_composite to factorize fat-pointer + -- building. function Create_Maybe_Fat_Array_Element (Arr : Mnode; Arr_Type : Iir) return Mnode; diff --git a/src/vhdl/translate/trans-helpers2.adb b/src/vhdl/translate/trans-helpers2.adb index a773fa7aa..dfaa1c8d6 100644 --- a/src/vhdl/translate/trans-helpers2.adb +++ b/src/vhdl/translate/trans-helpers2.adb @@ -234,7 +234,8 @@ package body Trans.Helpers2 is Res := E2M (Val, Type_Info, Mode_Value); case Type_Info.Type_Mode is when Type_Mode_Arrays => - Res := Chap3.Get_Composite_Base (Res); + null; + -- Res := Chap3.Get_Composite_Base (Res); -- Res := Chap3.Convert_Array_Base (Res); when Type_Mode_Records => Res := Stabilize (Res); @@ -250,7 +251,8 @@ package body Trans.Helpers2 is Index : O_Dnode) return O_Enode is begin - return M2E (Chap3.Index_Base (Val, Targ_Type, New_Obj_Value (Index))); + return M2E (Chap6.Translate_Indexed_Name_By_Offset + (Val, Targ_Type, Index)); end Gen_Oenode_Update_Data_Array; function Gen_Oenode_Update_Data_Record -- cgit v1.2.3