aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2022-10-01 18:30:59 +0200
committerTristan Gingold <tgingold@free.fr>2022-10-01 18:30:59 +0200
commit9c17ff87468773dd87d743c6eb20eb774ce24f8b (patch)
treee4d17dbbb951b6926d926a483be4a4e434426f23 /src/synth
parentd7c93e9d72f8ddb29446d525c430098f61e8f9b3 (diff)
downloadghdl-9c17ff87468773dd87d743c6eb20eb774ce24f8b.tar.gz
ghdl-9c17ff87468773dd87d743c6eb20eb774ce24f8b.tar.bz2
ghdl-9c17ff87468773dd87d743c6eb20eb774ce24f8b.zip
synth: avoid a crash on literal overflow
Diffstat (limited to 'src/synth')
-rw-r--r--src/synth/synth-vhdl_expr.adb11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/synth/synth-vhdl_expr.adb b/src/synth/synth-vhdl_expr.adb
index 392bd1535..a227e7511 100644
--- a/src/synth/synth-vhdl_expr.adb
+++ b/src/synth/synth-vhdl_expr.adb
@@ -2155,9 +2155,18 @@ package body Synth.Vhdl_Expr is
when Iir_Kind_Integer_Literal =>
declare
Res : Valtyp;
+ V : Int64;
begin
Res := Create_Value_Memory (Expr_Type, Current_Pool);
- Write_Discrete (Res, Get_Value (Expr));
+ V := Get_Value (Expr);
+ if Expr_Type.Sz = 4
+ and then (V < Int64 (Int32'First) or V > Int64 (Int32'Last))
+ then
+ -- TODO: should not exist, should be an overflow.
+ Error_Msg_Synth (Syn_Inst, Expr, "value out of range");
+ return No_Valtyp;
+ end if;
+ Write_Discrete (Res, V);
return Res;
end;
when Iir_Kind_Floating_Point_Literal =>