Maximum total count of errors before the compiler unconditionally bails out is now 200.

If more than 20 errors occur on the same source line, the compiler will immediately bail out.
This commit is contained in:
acqn 2023-11-27 20:39:15 +08:00
parent ab0ab8e36f
commit 79214530e0
1 changed files with 11 additions and 1 deletions

View File

@ -61,6 +61,8 @@
/* Count of errors/warnings */
unsigned ErrorCount = 0;
unsigned WarningCount = 0;
unsigned RecentLineNo = 0;
unsigned RecentErrorCount = 0;
/* Warning and error options */
IntStack WarnEnable = INTSTACK(1); /* Enable warnings */
@ -205,8 +207,16 @@ static void IntError (const char* Filename, unsigned LineNo, const char* Msg, va
if (Line) {
Print (stderr, 1, "Input: %.*s\n", (int) SB_GetLen (Line), SB_GetConstBuf (Line));
}
++ErrorCount;
if (ErrorCount > 20) {
if (RecentLineNo != LineNo) {
RecentLineNo = LineNo;
RecentErrorCount = 0;
} else {
++RecentErrorCount;
}
if (RecentErrorCount > 20 || ErrorCount > 200) {
Fatal ("Too many errors");
}
}