From a2c0447aeb1e1b3fca1d84716a2a97a5f65d3c30 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Tue, 7 May 2019 18:45:33 +0200 Subject: vhdl: Add a warning for null range in discrete type declaration. For issue #810 --- src/vhdl/vhdl-evaluation.adb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/vhdl/vhdl-evaluation.adb') diff --git a/src/vhdl/vhdl-evaluation.adb b/src/vhdl/vhdl-evaluation.adb index 65d099a42..6363411aa 100644 --- a/src/vhdl/vhdl-evaluation.adb +++ b/src/vhdl/vhdl-evaluation.adb @@ -3487,6 +3487,20 @@ package body Vhdl.Evaluation is end case; end Eval_Discrete_Type_Length; + function Eval_Is_Null_Discrete_Range (Rng : Iir) return Boolean + is + Left, Right : Iir_Int64; + begin + Left := Eval_Pos (Get_Left_Limit (Rng)); + Right := Eval_Pos (Get_Right_Limit (Rng)); + case Get_Direction (Rng) is + when Iir_To => + return Right < Left; + when Iir_Downto => + return Left < Right; + end case; + end Eval_Is_Null_Discrete_Range; + function Eval_Pos (Expr : Iir) return Iir_Int64 is begin case Get_Kind (Expr) is -- cgit v1.2.3