From 79214530e01e751773da6627142e40f0d5a6d5c6 Mon Sep 17 00:00:00 2001 From: acqn <acqn163@outlook.com> Date: Mon, 27 Nov 2023 20:39:15 +0800 Subject: [PATCH] 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. --- src/cc65/error.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/cc65/error.c b/src/cc65/error.c index 39b067825..2ad7133ed 100644 --- a/src/cc65/error.c +++ b/src/cc65/error.c @@ -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"); } }