diff options
author | Tristan Gingold <tgingold@free.fr> | 2021-11-17 04:37:25 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2021-11-17 04:40:40 +0100 |
commit | c5a6b553f4e4a7517ce8de8575b7c7d5710c070c (patch) | |
tree | 072d5301c3504063351f1fd1517216d038868534 /src/vhdl | |
parent | ea914a441cb16e48a5d50c386f681cd6dab6c385 (diff) | |
download | ghdl-c5a6b553f4e4a7517ce8de8575b7c7d5710c070c.tar.gz ghdl-c5a6b553f4e4a7517ce8de8575b7c7d5710c070c.tar.bz2 ghdl-c5a6b553f4e4a7517ce8de8575b7c7d5710c070c.zip |
vhdl-evaluation: use grt to compute value attribute for integers.
For #1913
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/vhdl-evaluation.adb | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/src/vhdl/vhdl-evaluation.adb b/src/vhdl/vhdl-evaluation.adb index 36ca4c1af..57bc6f915 100644 --- a/src/vhdl/vhdl-evaluation.adb +++ b/src/vhdl/vhdl-evaluation.adb @@ -33,6 +33,7 @@ with Vhdl.Ieee.Std_Logic_1164; with Grt.Types; with Grt.Fcvt; with Grt.To_Strings; +with Grt.Values; package body Vhdl.Evaluation is -- If FORCE is true, always return a literal. @@ -2774,7 +2775,22 @@ package body Vhdl.Evaluation is begin case Get_Kind (Base_Type) is when Iir_Kind_Integer_Type_Definition => - return Build_Discrete (Int64'Value (Value1), Orig); + declare + use Grt.Values; + use Grt.Types; + Res : Value_I64_Result; + begin + Res := Value_I64 (To_Std_String_Basep (Value1'Address), + Value1'Length, 0); + if Res.Status = Value_Ok then + return Build_Discrete (Int64 (Res.Val), Orig); + else + Warning_Msg_Sem + (Warnid_Runtime_Error, +Get_Parameter (Orig), + "incorrect parameter for value attribute"); + return Build_Overflow (Orig); + end if; + end; when Iir_Kind_Enumeration_Type_Definition => return Build_Enumeration_Value (Value1, Base_Type, Orig); when Iir_Kind_Floating_Type_Definition => @@ -2784,11 +2800,6 @@ package body Vhdl.Evaluation is when others => Error_Kind ("eval_value_attribute", Base_Type); end case; - exception - when Constraint_Error => - Warning_Msg_Sem (Warnid_Runtime_Error, +Orig, - "incorrect parameter for value attribute"); - return Build_Overflow (Orig); end; end Eval_Value_Attribute; |