diff options
author | Tristan Gingold <tgingold@free.fr> | 2022-06-19 16:16:56 +0200 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2022-06-19 16:16:56 +0200 |
commit | c54082b2cfa536c6bf97128d7725eadfae0fe4f8 (patch) | |
tree | dbd5bb23e1fe0ace0deb197778acf35cf4a292cd /src | |
parent | a952de22c794dc475bb5752378426cf3ec07fdd8 (diff) | |
download | ghdl-c54082b2cfa536c6bf97128d7725eadfae0fe4f8.tar.gz ghdl-c54082b2cfa536c6bf97128d7725eadfae0fe4f8.tar.bz2 ghdl-c54082b2cfa536c6bf97128d7725eadfae0fe4f8.zip |
vhdl-sem_expr: check expression index range for aggregate. Fix #2066
Diffstat (limited to 'src')
-rw-r--r-- | src/vhdl/vhdl-sem_expr.adb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/vhdl/vhdl-sem_expr.adb b/src/vhdl/vhdl-sem_expr.adb index 596638464..8a7ea0d89 100644 --- a/src/vhdl/vhdl-sem_expr.adb +++ b/src/vhdl/vhdl-sem_expr.adb @@ -3562,6 +3562,31 @@ package body Vhdl.Sem_Expr is "element is out of the bounds"); end if; + if Is_Array + and then Get_Kind (El) = Iir_Kind_Choice_By_Range + then + declare + Ch_Rng : constant Iir := Get_Choice_Range (El); + Expr_Type : constant Iir := Get_Type (Expr); + Idx : Iir; + begin + if Get_Expr_Staticness (Ch_Rng) = Locally + and then Get_Index_Constraint_Flag (Expr_Type) + then + Idx := Get_Index_Type (Expr_Type, 0); + if Get_Type_Staticness (Idx) = Locally + and then (Eval_Discrete_Type_Length (Idx) + /= Eval_Discrete_Range_Length (Ch_Rng)) + then + Warning_Msg_Sem (Warnid_Runtime_Error, +Expr, + "length mismatch"); + Expr := Build_Overflow (Expr, Expr_Type); + Set_Associated_Expr (El, Expr); + end if; + end if; + end; + end if; + Expr_Staticness := Min (Expr_Staticness, El_Staticness); Info.Nbr_Assocs := Info.Nbr_Assocs + 1; |