From 27812b602d2dfc452895c156bf0376bdcda71c8c Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Mon, 16 Jan 2023 18:55:17 +0100 Subject: synth-vhdl_eval: add an overflow check --- src/synth/synth-vhdl_eval.adb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/synth') diff --git a/src/synth/synth-vhdl_eval.adb b/src/synth/synth-vhdl_eval.adb index 5b4728c4d..c96e24721 100644 --- a/src/synth/synth-vhdl_eval.adb +++ b/src/synth/synth-vhdl_eval.adb @@ -1176,6 +1176,7 @@ package body Synth.Vhdl_Eval is Lv : Ghdl_I64; Rv : Std_Integer; Res : Ghdl_I64; + R : Int64; Ovf : Boolean; begin Lv := Ghdl_I64 (Read_Discrete (Param1)); @@ -1183,9 +1184,12 @@ package body Synth.Vhdl_Eval is Grt.Arith.Exp_I64 (Lv, Rv, Res, Ovf); if Ovf then Error_Msg_Synth (Inst, Expr, "exponentiation overflow"); - Res := 0; + R := 0; + else + R := Int64 (Res); + Check_Integer_Overflow (Inst, R, Res_Typ, Expr); end if; - return Create_Memory_Discrete (Int64 (Res), Res_Typ); + return Create_Memory_Discrete (R, Res_Typ); end; when Iir_Predefined_Integer_Less_Equal -- cgit v1.2.3