the compiler does not remove empty functions/procedures if they are nested
Original Reporter info from Mantis: 440bx @440bx
-
Reporter name:
Original Reporter info from Mantis: 440bx @440bx
- Reporter name:
Description:
When an empty function/procedure is at the "top level", i.e, not nested and the directive {$OPTIMIZATION REMOVEEMPTYPROCS} is specified the compiler successfully removes the empty functions/procedures.
if the function/procedure is empty but nested in another function/procedure, the compiler fails to remove it.
Steps to reproduce:
Compile and examine the code produced by the following program:
{$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.
Mantis conversion info:
- Mantis ID: 36977
- OS: Windows
- OS Build: Win 7
- Platform: Intel
- Version: 3.0.4