diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-08-04 18:46:22 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-08-04 18:46:22 +0200 |
commit | c1f5f40de1a580ff708122b8f1a5e2f8d9e7cdc3 (patch) | |
tree | 21af9f1701f1a5f2b4c57802bc5a2dc7842f9634 /src/grt | |
parent | 8d61edaf274ff80d2b185c0af34f30efa73d969a (diff) | |
download | ghdl-c1f5f40de1a580ff708122b8f1a5e2f8d9e7cdc3.tar.gz ghdl-c1f5f40de1a580ff708122b8f1a5e2f8d9e7cdc3.tar.bz2 ghdl-c1f5f40de1a580ff708122b8f1a5e2f8d9e7cdc3.zip |
grt: fix crash in --dump-rti for array of unbounded records.
For #1420
Diffstat (limited to 'src/grt')
-rw-r--r-- | src/grt/grt-disp_rti.adb | 4 | ||||
-rw-r--r-- | src/grt/grt-rtis_addr.adb | 20 | ||||
-rw-r--r-- | src/grt/grt-rtis_addr.ads | 5 |
3 files changed, 26 insertions, 3 deletions
diff --git a/src/grt/grt-disp_rti.adb b/src/grt/grt-disp_rti.adb index 045ac6fb5..38f4d34f7 100644 --- a/src/grt/grt-disp_rti.adb +++ b/src/grt/grt-disp_rti.adb @@ -230,9 +230,7 @@ package body Grt.Disp_Rti is Put (Stream, ", "); end if; if Index = Last_Idx then - -- Humm, not always an array, and BOUNDS may not be followed - -- by subelement bounds. - Bounds2 := Array_Layout_To_Bounds (Bounds); + Bounds2 := Array_Layout_To_Element (Bounds, El_Rti); Disp_Value (Stream, El_Rti, Ctxt, Obj, Bounds2, Is_Sig); else Bounds2 := Bounds; diff --git a/src/grt/grt-rtis_addr.adb b/src/grt/grt-rtis_addr.adb index 4881a5abd..e02aa8e89 100644 --- a/src/grt/grt-rtis_addr.adb +++ b/src/grt/grt-rtis_addr.adb @@ -283,6 +283,26 @@ package body Grt.Rtis_Addr is return Layout + Ghdl_Index_Type'(Ghdl_Indexes_Type'Size / 8); end Array_Layout_To_Bounds; + function Array_Layout_To_Element + (Layout : Address; El_Rti : Ghdl_Rti_Access) return Address is + begin + case El_Rti.Kind is + when Ghdl_Rtik_Type_Array + | Ghdl_Rtik_Subtype_Array + | Ghdl_Rtik_Subtype_Unbounded_Array => + -- Trim size to pass the bounds + return Array_Layout_To_Bounds (Layout); + when Ghdl_Rtik_Type_Unbounded_Record + | Ghdl_Rtik_Subtype_Unbounded_Record => + -- Keep full layout. + return Layout; + when Ghdl_Rtik_Type_Record => + return Null_Address; + when others => + return Null_Address; + end case; + end Array_Layout_To_Element; + procedure Bound_To_Range (Bounds_Addr : Address; Def : Ghdl_Rtin_Type_Array_Acc; Res : out Ghdl_Range_Array) diff --git a/src/grt/grt-rtis_addr.ads b/src/grt/grt-rtis_addr.ads index eddd5274a..7bce81b66 100644 --- a/src/grt/grt-rtis_addr.ads +++ b/src/grt/grt-rtis_addr.ads @@ -95,6 +95,11 @@ package Grt.Rtis_Addr is function Array_Layout_To_Bounds (Layout : Address) return Address; + -- Return bounds (for arrays) or layout (for recors) of array + -- layout LAYOUT according to element type EL_RTI. + function Array_Layout_To_Element + (Layout : Address; El_Rti : Ghdl_Rti_Access) return Address; + -- Extract range of every dimension from bounds. procedure Bound_To_Range (Bounds_Addr : Address; Def : Ghdl_Rtin_Type_Array_Acc; |