* give a proper error if macros are too deeply nested

git-svn-id: trunk@48357 -
This commit is contained in:
florian 2021-01-23 21:29:37 +00:00
parent e3481eecfb
commit 9803318fef
3 changed files with 20 additions and 2 deletions

1
.gitattributes vendored
View File

@ -16702,6 +16702,7 @@ tests/webtbf/tw37476.pp svneol=native#text/pascal
tests/webtbf/tw37763.pp svneol=native#text/pascal
tests/webtbf/tw3790.pp svneol=native#text/plain
tests/webtbf/tw3812.pp svneol=native#text/plain
tests/webtbf/tw38287.pp svneol=native#text/pascal
tests/webtbf/tw38289a.pp svneol=native#text/pascal
tests/webtbf/tw38289b.pp svneol=native#text/pascal
tests/webtbf/tw3930a.pp svneol=native#text/plain

View File

@ -135,6 +135,8 @@ interface
{ if nexttoken<>NOTOKEN, then nexttokenpos holds its filepos }
next_filepos : tfileposinfo;
{ current macro nesting depth }
macro_nesting_depth,
comment_level,
yylexcount : longint;
ignoredirectives : TFPHashList; { ignore directives, used to give warnings only once }
@ -2922,7 +2924,10 @@ type
if assigned(inputfile.next) then
begin
if inputfile.is_macro then
to_dispose:=inputfile
begin
to_dispose:=inputfile;
dec(macro_nesting_depth);
end
else
begin
to_dispose:=nil;
@ -3686,6 +3691,7 @@ type
addfile(hp);
with inputfile do
begin
inc(macro_nesting_depth);
setmacro(p,len);
{ local buffer }
inputbuffer:=buf;
@ -4868,7 +4874,7 @@ type
mac:=tmacro(search_macro(pattern));
if assigned(mac) and (not mac.is_compiler_var) and (assigned(mac.buftext)) then
begin
if yylexcount<max_macro_nesting then
if (yylexcount<max_macro_nesting) and (macro_nesting_depth<max_macro_nesting) then
begin
mac.is_used:=true;
inc(yylexcount);

11
tests/webtbf/tw38287.pp Normal file
View File

@ -0,0 +1,11 @@
{$macro on}
var
a,b,s : real;
begin
a:=1;
b:=2;
{$define sum:=a+b }
{$define b:=sum} { DONT do this !!!}
s:=sum; { Will be infinitely recursively expanded... }
end.