diff options
author | Tristan Gingold <tgingold@free.fr> | 2018-11-12 00:57:30 +0100 |
---|---|---|
committer | Tristan Gingold <tgingold@free.fr> | 2018-11-12 01:09:44 +0100 |
commit | 2fc9b6a808b146674e48c95a1349785bae4f77dc (patch) | |
tree | bb620b6b6d639b34f22ccde7e192be2a9db41d6e /src/vhdl | |
parent | 79b0c2ab26ccf92abd3659e30b346424f9cabdc5 (diff) | |
download | ghdl-2fc9b6a808b146674e48c95a1349785bae4f77dc.tar.gz ghdl-2fc9b6a808b146674e48c95a1349785bae4f77dc.tar.bz2 ghdl-2fc9b6a808b146674e48c95a1349785bae4f77dc.zip |
trans-chap7: fix overflow in vhdl 08 array aggregate.
Fix #659
Fix #649
Diffstat (limited to 'src/vhdl')
-rw-r--r-- | src/vhdl/translate/trans-chap7.adb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/vhdl/translate/trans-chap7.adb b/src/vhdl/translate/trans-chap7.adb index e93dce632..20f7185d1 100644 --- a/src/vhdl/translate/trans-chap7.adb +++ b/src/vhdl/translate/trans-chap7.adb @@ -2973,15 +2973,24 @@ package body Trans.Chap7 is El := Get_Association_Choices_Chain (Aggr); P := 0; loop - if El = Null_Iir then - return; - end if; + exit when El = Null_Iir; exit when Get_Kind (El) /= Iir_Kind_Choice_By_None; Do_Assign (El); - P := P + 1; + if not Final or else Get_Element_Type_Flag (El) then + P := P + 1; + else + P := P + Natural + (Eval_Discrete_Type_Length + (Get_Index_Type (Get_Type (Get_Associated_Expr (El)), 0))); + end if; El := Get_Chain (El); end loop; + -- End of chain. + if El = Null_Iir then + return; + end if; + pragma Assert (Get_Kind (El) = Iir_Kind_Choice_By_Others); -- Handle others. |