From 060d785216fd7006482608473341354ade78f8b9 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Sun, 26 Jan 2020 17:04:05 +0100 Subject: synth: avoid crash on incorrect slice direction. For #1116 --- src/synth/netlists-builders.adb | 1 - src/synth/synth-expr.adb | 10 ++++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/synth/netlists-builders.adb b/src/synth/netlists-builders.adb index c205ef318..c591c38a8 100644 --- a/src/synth/netlists-builders.adb +++ b/src/synth/netlists-builders.adb @@ -1343,7 +1343,6 @@ package body Netlists.Builders is is Wd : constant Width := Get_Width (I); pragma Assert (Wd /= No_Width); - pragma Assert (W > 0); pragma Assert (W + Off <= Wd); Inst : Instance; O : Net; diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb index 1b3e05df7..8e334cc2a 100644 --- a/src/synth/synth-expr.adb +++ b/src/synth/synth-expr.adb @@ -1323,6 +1323,11 @@ package body Synth.Expr is Error_Msg_Synth (+Name, "direction mismatch in slice"); Off := 0; Wd := 0; + if Dir = Iir_To then + Res_Bnd := (Dir => Iir_To, Left => 1, Right => 0, Len => 0); + else + Res_Bnd := (Dir => Iir_Downto, Left => 0, Right => 1, Len => 0); + end if; return; end if; @@ -1418,6 +1423,11 @@ package body Synth.Expr is Inp := No_Net; Off := 0; Wd := 0; + if Dir = Iir_To then + Res_Bnd := (Dir => Iir_To, Left => 1, Right => 0, Len => 0); + else + Res_Bnd := (Dir => Iir_Downto, Left => 0, Right => 1, Len => 0); + end if; return; end if; -- cgit v1.2.3