aboutsummaryrefslogtreecommitdiffstats
path: root/src/synth/synth-stmts.adb
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-04-21 07:41:09 +0200
committerTristan Gingold <tgingold@free.fr>2020-04-21 07:41:09 +0200
commitfaef2db5bbe258f9ac4f9e357f8db878903ca528 (patch)
tree3ae80f284fd99de18ab6bbdd9a78751bbfdcc7bb /src/synth/synth-stmts.adb
parent42c83fcb04b35e4dce3d1675d90f46fbfe144c4a (diff)
downloadghdl-faef2db5bbe258f9ac4f9e357f8db878903ca528.tar.gz
ghdl-faef2db5bbe258f9ac4f9e357f8db878903ca528.tar.bz2
ghdl-faef2db5bbe258f9ac4f9e357f8db878903ca528.zip
synth-stmts: add a limit to the number of iterations. Fix #1242
Diffstat (limited to 'src/synth/synth-stmts.adb')
-rw-r--r--src/synth/synth-stmts.adb11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/synth/synth-stmts.adb b/src/synth/synth-stmts.adb
index efece924c..61833ab58 100644
--- a/src/synth/synth-stmts.adb
+++ b/src/synth/synth-stmts.adb
@@ -2328,6 +2328,7 @@ package body Synth.Stmts is
Cond : constant Node := Get_Condition (Stmt);
Val : Valtyp;
Lc : aliased Loop_Context (Mode_Dynamic);
+ Iter_Nbr : Natural;
begin
Lc := (Mode => Mode_Dynamic,
Prev_Loop => C.Cur_Loop,
@@ -2339,6 +2340,8 @@ package body Synth.Stmts is
Wire_Mark => No_Wire_Id);
C.Cur_Loop := Lc'Unrestricted_Access;
+ Iter_Nbr := 0;
+
Loop_Control_Init (C, Stmt);
loop
@@ -2371,6 +2374,14 @@ package body Synth.Stmts is
then
exit;
end if;
+
+ Iter_Nbr := Iter_Nbr + 1;
+ if Iter_Nbr > Flags.Flag_Max_Loop and Flags.Flag_Max_Loop /= 0 then
+ Error_Msg_Synth
+ (+Stmt, "maximum number of iterations (%v) reached",
+ +Uns32 (Flags.Flag_Max_Loop));
+ exit;
+ end if;
end loop;
Loop_Control_Finish (C);