aboutsummaryrefslogtreecommitdiffstats
path: root/src/vhdl/vhdl-sem_names.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2023-01-25 08:16:24 +0100
committerTristan Gingold <tgingold@free.fr>2023-01-25 20:57:31 +0100
commitc92813bb456ffc4d7cadee441397d22742f89fc6 (patch)
tree5725b1aefbae5dbafbf83180fb0049fa3b85b736 /src/vhdl/vhdl-sem_names.adb
parentf89f72892acd07f4e161cf87370159f67836e212 (diff)
downloadghdl-c92813bb456ffc4d7cadee441397d22742f89fc6.tar.gz
ghdl-c92813bb456ffc4d7cadee441397d22742f89fc6.tar.bz2
ghdl-c92813bb456ffc4d7cadee441397d22742f89fc6.zip
vhdl: improve range checks, fix #2323
Diffstat (limited to 'src/vhdl/vhdl-sem_names.adb')
-rw-r--r--src/vhdl/vhdl-sem_names.adb25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/vhdl/vhdl-sem_names.adb b/src/vhdl/vhdl-sem_names.adb
index 800e6183f..b52e7e7ae 100644
--- a/src/vhdl/vhdl-sem_names.adb
+++ b/src/vhdl/vhdl-sem_names.adb
@@ -720,7 +720,6 @@ package body Vhdl.Sem_Names is
end if;
Index_Type := Get_Index_Type (Index_List, 0);
- Prefix_Rng := Eval_Static_Range (Index_Type);
-- LRM93 6.5
-- It is an error if either the bounds of the discrete range does not
@@ -734,7 +733,7 @@ package body Vhdl.Sem_Names is
-- The bounds of the discrete range [...] must be of the
-- type of the index of the array.
Suffix := Get_Suffix (Name);
- Suffix := Sem_Discrete_Range (Suffix, Index_Type, False);
+ Suffix := Sem_Discrete_Range (Suffix, Index_Type);
if Suffix = Null_Iir then
return;
end if;
@@ -766,16 +765,22 @@ package body Vhdl.Sem_Names is
if Get_Kind (Prefix_Type) = Iir_Kind_Array_Subtype_Definition
and then Get_Index_Constraint_Flag (Prefix_Type)
and then Staticness = Locally
- and then Prefix_Rng /= Null_Iir
- and then Get_Direction (Suffix_Rng) /= Get_Direction (Prefix_Rng)
+ and then Get_Type_Staticness (Index_Type) = Locally
then
- if False and then Flags.Vhdl_Std = Vhdl_87 then
- -- emit a warning for a null slice.
- Warning_Msg_Sem (Warnid_Runtime_Error, +Name,
- "direction mismatch results in a null slice");
+ Prefix_Rng := Eval_Static_Range (Index_Type);
+ if Get_Direction (Suffix_Rng) /= Get_Direction (Prefix_Rng) then
+ if False and then Flags.Vhdl_Std = Vhdl_87 then
+ -- emit a warning for a null slice.
+ Warning_Msg_Sem (Warnid_Runtime_Error, +Name,
+ "direction mismatch results in a null slice");
+ end if;
+ Error_Msg_Sem (+Name, "direction of the range mismatch");
+ else
+ Check_Range_Compatibility (Suffix_Rng, Prefix_Rng);
+ -- May have changed in case of overflow.
+ Staticness := Get_Expr_Staticness (Suffix_Rng);
end if;
- Error_Msg_Sem (+Name, "direction of the range mismatch");
end if;
-- LRM93 7.4.1
@@ -2769,7 +2774,7 @@ package body Vhdl.Sem_Names is
Set_Index_List (Res, Create_Iir_Flist (1));
Set_Nth_Element (Get_Index_List (Res), 0, Actual);
when Iir_Kind_Slice_Name =>
- Actual := Sem_Discrete_Range (Actual, Itype, False);
+ Actual := Sem_Discrete_Range (Actual, Itype);
if Actual = Null_Iir then
return Null_Iir;
end if;