Hello,
{$OPTIMIZATION REMOVEEMPTYPROCS} seems to work as expected when the empty procedure is _not_ nested. When the procedure is nested, there does not seem to be a way to convince the compiler to remove it.
consider the following example:
{$OPTIMIZATION REMOVEEMPTYPROCS}
// {$DEFINE TRACK_ERROR_LINE}
program EmptyProc;
procedure OuterProc();
var
NotNeeded1, NotNeeded2 : integer;
p : pchar;
procedure TrackErrorLine();
begin
{$IFDEF TRACK_ERROR_LINE} writeln('Error line : ', p); {$ENDIF}
end;
procedure Aprocedure(var x : integer);
var
a, b, c : integer;
begin
{ give the compiler something to do }
x := a * b + c;
{ do plenty of other stuff }
{$IFDEF TRACK_ERROR_LINE} p := {$I %LINE%}; {$ENDIF}
TrackErrorLine();
end;
begin
Aprocedure(NotNeeded1);
end;
begin
OuterProc();
writeln('press enter/return to end this program');
readln;
end.
Changing the code to remove OuterProc (and include a call to Aprocedure instead of OuterProc) thereby making the TrackErrorLine() procedure not nested will yield the desired and expected results but, not otherwise.
Suggestions on how to convince the compiler to remove the empty nested proc are most welcome.
Thank you.