mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-25 01:51:37 +02:00
* give a proper error if macros are too deeply nested
git-svn-id: trunk@48357 -
This commit is contained in:
parent
e3481eecfb
commit
9803318fef
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -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
|
||||
|
@ -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
11
tests/webtbf/tw38287.pp
Normal file
@ -0,0 +1,11 @@
|
||||
{$macro on}
|
||||
var
|
||||
a,b,s : real;
|
||||
|
||||
begin
|
||||
a:=1;
|
||||
b:=2;
|
||||
{$define sum:=a+b }
|
||||
{$define b:=sum} { DON’T do this !!!}
|
||||
s:=sum; { Will be infinitely recursively expanded... }
|
||||
end.
|
Loading…
Reference in New Issue
Block a user