diff options
author | Tristan Gingold <tgingold@free.fr> | 2020-03-18 07:33:00 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2020-03-18 07:33:00 +0100 |
commit | 3939ce510a2eaa7f612078369a9032e12981efb1 (patch) | |
tree | 58e590e302a008a2c138e4f0dc0132673a1a19a6 /src/synth/synth-expr.adb | |
parent | 0b0133bf964f472103a551a590de05e20d8722f5 (diff) | |
download | ghdl-3939ce510a2eaa7f612078369a9032e12981efb1.tar.gz ghdl-3939ce510a2eaa7f612078369a9032e12981efb1.tar.bz2 ghdl-3939ce510a2eaa7f612078369a9032e12981efb1.zip |
synth-expr: handle length attribute for subtypes. Fix #1160
Diffstat (limited to 'src/synth/synth-expr.adb')
-rw-r--r-- | src/synth/synth-expr.adb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index ecb5f199b..1b730efa8 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -686,17 +686,25 @@ package body Synth.Expr is Prefix : constant Iir := Strip_Denoting_Name (Get_Prefix (Attr)); Dim : constant Natural := Vhdl.Evaluation.Eval_Attribute_Parameter_Or_1 (Attr); - Res : Value_Acc; + Obj : Value_Acc; + Typ : Type_Acc; begin -- Prefix is an array object or an array subtype. - Res := Synth_Name (Syn_Inst, Prefix); - if Res.Typ.Kind = Type_Vector then + if Get_Kind (Prefix) = Iir_Kind_Subtype_Declaration then + -- TODO: does this cover all the cases ? + Typ := Get_Value_Type (Syn_Inst, Get_Subtype_Indication (Prefix)); + else + Obj := Synth_Name (Syn_Inst, Prefix); + Typ := Obj.Typ; + end if; + + if Typ.Kind = Type_Vector then if Dim /= 1 then raise Internal_Error; end if; - return Res.Typ.Vbound; + return Typ.Vbound; else - return Res.Typ.Abounds.D (Iir_Index32 (Dim)); + return Typ.Abounds.D (Iir_Index32 (Dim)); end if; end Synth_Array_Attribute; |