diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-04-23 04:37:42 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-04-23 04:37:42 +0200 |
commit | 90a760965427e064c50317f0609d6f6acc8b1def (patch) | |
tree | a537bbe3f56d2a0a0f030a58ba6b06d8ef65d8c0 /src/vhdl/evaluation.adb | |
parent | 5179989efd6ae255c38af9d00a4aad02f0ce58b7 (diff) | |
download | ghdl-90a760965427e064c50317f0609d6f6acc8b1def.tar.gz ghdl-90a760965427e064c50317f0609d6f6acc8b1def.tar.bz2 ghdl-90a760965427e064c50317f0609d6f6acc8b1def.zip |
Avoid a crash on incorrect range dimension.
Diffstat (limited to 'src/vhdl/evaluation.adb')
-rw-r--r-- | src/vhdl/evaluation.adb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/vhdl/evaluation.adb b/src/vhdl/evaluation.adb index 9d2290fdf..603f8af21 100644 --- a/src/vhdl/evaluation.adb +++ b/src/vhdl/evaluation.adb @@ -3388,6 +3388,7 @@ package body Evaluation is when Iir_Kind_Range_Array_Attribute | Iir_Kind_Reverse_Range_Array_Attribute => declare + Indexes_List : Iir_Flist; Prefix : Iir; Res : Iir; Dim : Natural; @@ -3402,9 +3403,15 @@ package body Evaluation is -- Unconstrained object. return Null_Iir; end if; + Indexes_List := Get_Index_Subtype_List (Prefix); Dim := Eval_Attribute_Parameter_Or_1 (Expr); - Expr := Get_Nth_Element - (Get_Index_Subtype_List (Prefix), Dim - 1); + if Dim < 1 + or else Dim > Get_Nbr_Elements (Indexes_List) + then + -- Avoid cascaded errors. + Dim := 1; + end if; + Expr := Get_Nth_Element (Indexes_List, Dim - 1); if Kind = Iir_Kind_Reverse_Range_Array_Attribute then Expr := Eval_Static_Range (Expr); |