compiler: don't generate code for empty initialization and finalization sections (with help of Florian) (issue #0013482)

git-svn-id: trunk@14543 -
This commit is contained in:
paul 2010-01-05 16:07:37 +00:00
parent 95ccc3ea40
commit 8b27daae2c
2 changed files with 23 additions and 15 deletions

View File

@ -1209,7 +1209,7 @@ implementation
if not current_module.interface_only and (token=_FINALIZATION) then
begin
{ set module options }
current_module.flags:=current_module.flags or uf_finalize;
// current_module.flags:=current_module.flags or uf_finalize;
{ Compile the finalize }
finalize_procinfo:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize'),potype_unitfinalize,current_module.localsymtable);
@ -2138,7 +2138,7 @@ implementation
if token=_FINALIZATION then
begin
{ set module options }
current_module.flags:=current_module.flags or uf_finalize;
//current_module.flags:=current_module.flags or uf_finalize;
{ Parse the finalize }
finalize_procinfo:=create_main_proc(make_mangledname('',current_module.localsymtable,'finalize'),potype_unitfinalize,current_module.localsymtable);
finalize_procinfo.procdef.aliasnames.insert(make_mangledname('FINALIZE$',current_module.localsymtable,''));

View File

@ -207,21 +207,29 @@ implementation
begin
{ The library init code is already called and does not
need to be in the initfinal table (PFV) }
if not islibrary then
current_module.flags:=current_module.flags or uf_init;
block:=statement_block(_INITIALIZATION);
end
else if (token=_FINALIZATION) then
begin
if (current_module.flags and uf_finalize)<>0 then
block:=statement_block(_FINALIZATION)
{ optimize empty initialization block away }
if (tstatementnode(block).left=nil) then
FreeAndNil(block)
else
begin
{ can we allow no INITIALIZATION for DLL ??
I think it should work PM }
block:=nil;
exit;
end;
if not islibrary then
current_module.flags:=current_module.flags or uf_init;
end
else if token=_FINALIZATION then
begin
{ when a unit has only a finalization section, we can come to this
point when we try to read the nonh existing initalization section
so we've to check if we are really try to parse the finalization }
if current_procinfo.procdef.proctypeoption=potype_unitfinalize then
begin
block:=statement_block(_FINALIZATION);
{ optimize empty finalization block away }
if (tstatementnode(block).left=nil) then
FreeAndNil(block)
else
if not islibrary then
current_module.flags:=current_module.flags or uf_finalize;
end;
end
else
begin