diff options
author | Tristan Gingold <tgingold@free.fr> | 2023-01-16 18:55:17 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2023-01-16 18:57:52 +0100 |
commit | 27812b602d2dfc452895c156bf0376bdcda71c8c (patch) | |
tree | eeee76c0b09ea50e9ab95a72e12506ccaf661a2f /src | |
parent | 47def2be73f1a5f27f2c46db8cbc5a350f0f549e (diff) | |
download | ghdl-27812b602d2dfc452895c156bf0376bdcda71c8c.tar.gz ghdl-27812b602d2dfc452895c156bf0376bdcda71c8c.tar.bz2 ghdl-27812b602d2dfc452895c156bf0376bdcda71c8c.zip |
synth-vhdl_eval: add an overflow check
Diffstat (limited to 'src')
-rw-r--r-- | src/synth/synth-vhdl_eval.adb | 8 |
1 files changed, 6 insertions, 2 deletions
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 |