From 8d4e1bf0c2fd6635c735b42aebc3fe0645f270bf Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 25 Apr 2021 19:49:26 +0000 Subject: * decrease macro nesting counter early when expanding empty macro to avoid errors about too depth macro nesting, resolves #38802 git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@49265 3ad0048d-3df7-0310-abae-a5850022a9f2 --- compiler/scanner.pas | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'compiler') diff --git a/compiler/scanner.pas b/compiler/scanner.pas index b33f7a73c5..9632471f24 100644 --- a/compiler/scanner.pas +++ b/compiler/scanner.pas @@ -4883,12 +4883,21 @@ type inc(yylexcount); substitutemacro(pattern,mac.buftext,mac.buflen, mac.fileinfo.line,mac.fileinfo.fileindex); - { handle empty macros } + { handle empty macros } if c=#0 then - reload; - readtoken(false); - { that's all folks } - dec(yylexcount); + begin + reload; + { avoid macro nesting error in case of + a sequence of empty macros, see #38802 } + dec(yylexcount); + readtoken(false); + end + else + begin + readtoken(false); + { that's all folks } + dec(yylexcount); + end; exit; end else -- cgit v1.2.1