* properly process all child nodes of call nodes in foreachnode, resolves #40957

This commit is contained in:
florian 2024-10-19 23:40:55 +02:00
parent 431d4395ea
commit b8a4a72760
2 changed files with 34 additions and 0 deletions

View File

@ -243,6 +243,7 @@ implementation
result := foreachnode(procmethod,tnode(tcallnode(n).callinitblock),f,arg) or result;
result := foreachnode(procmethod,tcallnode(n).methodpointer,f,arg) or result;
result := foreachnode(procmethod,tcallnode(n).funcretnode,f,arg) or result;
result := foreachnode(procmethod,tnode(tcallnode(n).vmt_entry),f,arg) or result;
result := foreachnode(procmethod,tnode(tcallnode(n).callcleanupblock),f,arg) or result;
end;
callparan:
@ -351,6 +352,7 @@ implementation
result := foreachnodestatic(procmethod,tnode(tcallnode(n).callinitblock),f,arg) or result;
result := foreachnodestatic(procmethod,tcallnode(n).methodpointer,f,arg) or result;
result := foreachnodestatic(procmethod,tcallnode(n).funcretnode,f,arg) or result;
result := foreachnodestatic(procmethod,tnode(tcallnode(n).vmt_entry),f,arg) or result;
result := foreachnodestatic(procmethod,tnode(tcallnode(n).callcleanupblock),f,arg) or result;
end;
callparan:

32
tests/webtbs/tw40957.pp Normal file
View File

@ -0,0 +1,32 @@
program i20241020_01;
{$mode objfpc}
//{$OPTIMIZATION NODFA}
//{$OPTIMIZATION NOFORLOOP}
type
TObj = object
arr: array [0..512] of byte;
constructor init;
destructor done; virtual;
end;
const
cnt=44;
var
arr: array[0..cnt] of TObj;
i: int32;
constructor TObj.init;
begin
end;
destructor TObj.done;
begin
end;
begin
for i:=0 to cnt do arr[i].init;
for i:=0 to cnt do arr[i].done; // AV here in run-time
end.