diff options
author | Tristan Gingold <tgingold@free.fr> | 2021-03-13 07:47:47 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2021-03-13 08:01:45 +0100 |
commit | 301c417faec48049ab3ffe208bdbbc6098f482ad (patch) | |
tree | 6bb4ea980db61d3c7b4a3f9528315ee1ea01428d /src | |
parent | 29db6e5c0f8ed313315f83f5cf0ccfafc9ea00b3 (diff) | |
download | ghdl-301c417faec48049ab3ffe208bdbbc6098f482ad.tar.gz ghdl-301c417faec48049ab3ffe208bdbbc6098f482ad.tar.bz2 ghdl-301c417faec48049ab3ffe208bdbbc6098f482ad.zip |
synth: handle attributes of length 0. Fix #1680
Diffstat (limited to 'src')
-rw-r--r-- | src/synth/netlists.adb | 4 | ||||
-rw-r--r-- | src/synth/synth-decls.adb | 5 |
2 files changed, 6 insertions, 3 deletions
diff --git a/src/synth/netlists.adb b/src/synth/netlists.adb index 5a8b6e38d..18ca51992 100644 --- a/src/synth/netlists.adb +++ b/src/synth/netlists.adb @@ -1106,7 +1106,6 @@ package body Netlists is function Create_Pval4 (Len : Uns32) return Pval is - pragma Assert (Len > 0); Nwords : constant Uns32 := (Len + 31) / 32; Idx : constant Uns32 := Pval_Word_Table.Last + 1; Res : Uns32; @@ -1121,7 +1120,6 @@ package body Netlists is function Create_Pval2 (Len : Uns32) return Pval is - pragma Assert (Len > 0); Nwords : constant Uns32 := (Len + 31) / 32; Idx : constant Uns32 := Pval_Word_Table.Last + 1; Res : Uns32; @@ -1145,6 +1143,7 @@ package body Netlists is is pragma Assert (P <= Pval_Table.Last); Pval_Rec : Pval_Record renames Pval_Table.Table (P); + pragma Assert (Pval_Rec.Len > 0); pragma Assert (Off <= (Pval_Rec.Len - 1) / 32); Res : Logic_32; begin @@ -1161,6 +1160,7 @@ package body Netlists is is pragma Assert (P <= Pval_Table.Last); Pval_Rec : Pval_Record renames Pval_Table.Table (P); + pragma Assert (Pval_Rec.Len > 0); pragma Assert (Off <= (Pval_Rec.Len - 1) / 32); begin Pval_Word_Table.Table (Pval_Rec.Va_Idx + Off) := Val.Val; diff --git a/src/synth/synth-decls.adb b/src/synth/synth-decls.adb index f1835e5b9..d3a903b00 100644 --- a/src/synth/synth-decls.adb +++ b/src/synth/synth-decls.adb @@ -93,12 +93,15 @@ package body Synth.Decls is function Memtyp_To_Pval (Mt : Memtyp) return Pval is Len : constant Uns32 := (Mt.Typ.W + 31) / 32; - pragma Assert (Len > 0); Vec : Logvec_Array_Acc; Off : Uns32; Has_Zx : Boolean; Pv : Pval; begin + if Len = 0 then + return Create_Pval2 (0); + end if; + Vec := new Logvec_Array'(0 .. Digit_Index (Len - 1) => (0, 0)); Off := 0; Has_Zx := False; |