aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-04-06 19:07:08 +0200
committerTristan Gingold <tgingold@free.fr>2020-04-06 20:10:59 +0200
commitea7b6490368a4fceb370cc8bc7069133a3217285 (patch)
tree90defa71d2e14467572d634dca69b4155f3968fd /src
parentdd2ab958e24a7a1593e1bcefdc0c5365a47bb014 (diff)
downloadghdl-ea7b6490368a4fceb370cc8bc7069133a3217285.tar.gz
ghdl-ea7b6490368a4fceb370cc8bc7069133a3217285.tar.bz2
ghdl-ea7b6490368a4fceb370cc8bc7069133a3217285.zip
synth: check length for vector conversion. Fix #1199
Diffstat (limited to 'src')
-rw-r--r--src/synth/synth-expr.adb11
-rw-r--r--src/synth/synth-stmts.adb4
2 files changed, 10 insertions, 5 deletions
diff --git a/src/synth/synth-expr.adb b/src/synth/synth-expr.adb
index d5a32c327..c58454c0b 100644
--- a/src/synth/synth-expr.adb
+++ b/src/synth/synth-expr.adb
@@ -657,6 +657,11 @@ package body Synth.Expr is
is
Vtype : constant Type_Acc := Vt.Typ;
begin
+ if Vt = No_Valtyp then
+ -- Propagate error.
+ return No_Valtyp;
+ end if;
+
case Dtype.Kind is
when Type_Bit =>
pragma Assert (Vtype.Kind = Type_Bit);
@@ -706,9 +711,9 @@ package body Synth.Expr is
when Type_Vector =>
pragma Assert (Vtype.Kind = Type_Vector
or Vtype.Kind = Type_Slice);
- if False and then Dtype.W /= Vtype.W then
- -- TODO: bad width.
- raise Internal_Error;
+ if Dtype.W /= Vtype.W then
+ Error_Msg_Synth (+Loc, "mismatching vector length");
+ return No_Valtyp;
end if;
if Bounds then
return Reshape_Value (Vt, Dtype);
diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb
index aa1a737ac..6a7081810 100644
--- a/src/synth/synth-stmts.adb
+++ b/src/synth/synth-stmts.adb
@@ -98,11 +98,11 @@ package body Synth.Stmts is
Cval : Valtyp;
N : Net;
begin
- if Val = No_Valtyp then
+ Cval := Synth_Subtype_Conversion (Val, Typ, False, Loc);
+ if Cval = No_Valtyp then
-- In case of error.
return;
end if;
- Cval := Synth_Subtype_Conversion (Val, Typ, False, Loc);
N := Get_Net (Cval);
Phi_Assign (Build_Context, Wid, N, Offset);
end Synth_Assign;