aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl
diff options
context:
space:
mode:
Diffstat (limited to 'src/vhdl')
-rw-r--r--src/vhdl/errorout.ads6
-rw-r--r--src/vhdl/vhdl-evaluation.adb14
-rw-r--r--src/vhdl/vhdl-evaluation.ads3
-rw-r--r--src/vhdl/vhdl-sem_types.adb14
4 files changed, 34 insertions, 3 deletions
diff --git a/src/vhdl/errorout.ads b/src/vhdl/errorout.ads
index 8da60ee15..6825b1c0d 100644
--- a/src/vhdl/errorout.ads
+++ b/src/vhdl/errorout.ads
@@ -362,9 +362,9 @@ private
type Warnings_Setting is array (Msgid_Warnings) of Warning_Control_Type;
Default_Warnings : constant Warnings_Setting :=
- (Warnid_Binding | Warnid_Library | Warnid_Shared
- | Warnid_Pure | Warnid_Specs | Warnid_Hide
- | Warnid_Port => (Enabled => True, Error => False),
+ (Warnid_Library | Warnid_Binding | Warnid_Port | Warnid_Shared
+ | Warnid_Runtime_Error | Warnid_Pure | Warnid_Specs
+ | Warnid_Hide => (Enabled => True, Error => False),
others => (Enabled => False, Error => False));
-- Compute the column from Error_Record E.
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
diff --git a/src/vhdl/vhdl-evaluation.ads b/src/vhdl/vhdl-evaluation.ads
index 61c290ae1..6d913a4d2 100644
--- a/src/vhdl/vhdl-evaluation.ads
+++ b/src/vhdl/vhdl-evaluation.ads
@@ -127,6 +127,9 @@ package Vhdl.Evaluation is
-- Note: the range constraint may be an attribute or a subtype.
function Eval_Discrete_Range_Left (Constraint : Iir) return Iir;
+ -- Return true iff RNG is a null range.
+ function Eval_Is_Null_Discrete_Range (Rng : Iir) return Boolean;
+
-- Return the position of EXPR, ie the result of sub_type'pos (EXPR), where
-- sub_type is the type of expr.
-- EXPR must be of a discrete subtype.
diff --git a/src/vhdl/vhdl-sem_types.adb b/src/vhdl/vhdl-sem_types.adb
index 3ec8586ce..0cc7bf314 100644
--- a/src/vhdl/vhdl-sem_types.adb
+++ b/src/vhdl/vhdl-sem_types.adb
@@ -265,6 +265,13 @@ package body Vhdl.Sem_Types is
case Get_Kind (Get_Base_Type (Get_Type (Get_Left_Limit (Rng)))) is
when Iir_Kind_Integer_Type_Definition =>
+ if Get_Expr_Staticness (Rng) = Locally
+ and then Eval_Is_Null_Discrete_Range (Rng)
+ then
+ Warning_Msg_Sem
+ (Warnid_Runtime_Error, +Expr,
+ "integer type %i has a null range", (1 => +Decl));
+ end if;
Res := Create_Integer_Type (Expr, Rng, Decl);
when Iir_Kind_Floating_Type_Definition =>
declare
@@ -374,6 +381,13 @@ package body Vhdl.Sem_Types is
Get_Range_Constraint (Universal_Integer_Subtype_Definition);
else
Range_Expr1 := Eval_Range_If_Static (Range_Expr1);
+ if Get_Expr_Staticness (Range_Expr1) = Locally
+ and then Eval_Is_Null_Discrete_Range (Range_Expr1)
+ then
+ Warning_Msg_Sem
+ (Warnid_Runtime_Error, +Range_Expr,
+ "physical type %i has a null range", (1 => +Decl));
+ end if;
end if;
-- Create the subtype.