aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2021-09-13 21:51:43 +0200
committerTristan Gingold <tgingold@free.fr>2021-09-14 04:16:51 +0200
commit77476d6ecc45f1761125524cbdeddfe74e3b157a (patch)
treef6107b185b8c92f28e99d129e839a0c28fbe211e /src/vhdl
parent95cbcc921d92d58dbd25d328de60c18976083d2a (diff)
downloadghdl-77476d6ecc45f1761125524cbdeddfe74e3b157a.tar.gz
ghdl-77476d6ecc45f1761125524cbdeddfe74e3b157a.tar.bz2
ghdl-77476d6ecc45f1761125524cbdeddfe74e3b157a.zip
ortho: for slices, get element size from the result type
and not from the object type. Fix #1862
Diffstat (limited to 'src/vhdl')
-rw-r--r--src/vhdl/translate/trans-chap3.adb4
-rw-r--r--src/vhdl/translate/trans-chap6.adb12
2 files changed, 11 insertions, 5 deletions
diff --git a/src/vhdl/translate/trans-chap3.adb b/src/vhdl/translate/trans-chap3.adb
index 9291bd38b..f09601066 100644
--- a/src/vhdl/translate/trans-chap3.adb
+++ b/src/vhdl/translate/trans-chap3.adb
@@ -1180,6 +1180,10 @@ package body Trans.Chap3 is
if Info.Type_Locally_Constrained then
Arr := Arr_Def;
else
+ -- If the element has been constrained, there is no ortho array
+ -- with the constrained element. So use the base type as a fall
+ -- back (if the element cannot be constrained, it is the same as the
+ -- base type element).
Arr := Get_Base_Type (Arr_Def);
end if;
return Get_Element_Subtype (Arr);
diff --git a/src/vhdl/translate/trans-chap6.adb b/src/vhdl/translate/trans-chap6.adb
index 1e5fe6bc2..1f4edde79 100644
--- a/src/vhdl/translate/trans-chap6.adb
+++ b/src/vhdl/translate/trans-chap6.adb
@@ -558,15 +558,14 @@ package body Trans.Chap6 is
-- Type of the first (and only) index of the prefix array type.
Index_Type : constant Iir := Get_Index_Type (Prefix_Type, 0);
- -- Element type.
- El_Type : constant Iir :=
- Chap3.Get_Element_Subtype_For_Info (Prefix_Type);
- El_Tinfo : constant Type_Info_Acc := Get_Info (El_Type);
-
-- Type of the slice.
Slice_Type : constant Iir := Get_Type (Expr);
Slice_Info : Type_Info_Acc;
+ -- Element type.
+ El_Type : Iir;
+ El_Tinfo : Type_Info_Acc;
+
-- Suffix of the slice (discrete range).
Expr_Range : constant Iir := Get_Suffix (Expr);
@@ -597,6 +596,9 @@ package body Trans.Chap6 is
Prefix_Var := Prefix;
+ El_Type := Chap3.Get_Element_Subtype_For_Info (Slice_Type);
+ El_Tinfo := Get_Info (El_Type);
+
if Is_Unbounded_Type (El_Tinfo) then
-- Copy layout of element before building the bounds
-- pragma Assert (Is_Unbounded_Type (Prefix_Info));