mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-19 10:09:19 +02:00
* limit initialization to register variables which really need to be initialized
git-svn-id: trunk@29569 -
This commit is contained in:
parent
0f83e24145
commit
69ac7dd7ef
@ -4387,7 +4387,7 @@ implementation
|
|||||||
var
|
var
|
||||||
href : treference;
|
href : treference;
|
||||||
begin
|
begin
|
||||||
if (tsym(p).typ=staticvarsym) then
|
if (tsym(p).typ=staticvarsym) and not(tstaticvarsym(p).noregvarinitneeded) then
|
||||||
begin
|
begin
|
||||||
{ Static variables can have the initialloc only set to LOC_CxREGISTER
|
{ Static variables can have the initialloc only set to LOC_CxREGISTER
|
||||||
or LOC_INVALID, for explaination see gen_alloc_symtable (PFV) }
|
or LOC_INVALID, for explaination see gen_alloc_symtable (PFV) }
|
||||||
|
@ -1334,13 +1334,21 @@ implementation
|
|||||||
{ iterate through life info of the first node }
|
{ iterate through life info of the first node }
|
||||||
for i:=0 to dfabuilder.nodemap.count-1 do
|
for i:=0 to dfabuilder.nodemap.count-1 do
|
||||||
begin
|
begin
|
||||||
if DFASetIn(GetUserCode.optinfo^.life,i) and
|
if DFASetIn(GetUserCode.optinfo^.life,i) then
|
||||||
{ do not warn about parameters passed by var }
|
begin
|
||||||
not((tnode(dfabuilder.nodemap[i]).nodetype=loadn) and (tloadnode(dfabuilder.nodemap[i]).symtableentry.typ=paravarsym) and
|
{ do not warn about parameters passed by var }
|
||||||
|
if not((tnode(dfabuilder.nodemap[i]).nodetype=loadn) and (tloadnode(dfabuilder.nodemap[i]).symtableentry.typ=paravarsym) and
|
||||||
(tparavarsym(tloadnode(dfabuilder.nodemap[i]).symtableentry).varspez=vs_var) and
|
(tparavarsym(tloadnode(dfabuilder.nodemap[i]).symtableentry).varspez=vs_var) and
|
||||||
{ function result is passed by var but it must be initialized }
|
{ function result is passed by var but it must be initialized }
|
||||||
not(vo_is_funcret in tparavarsym(tloadnode(dfabuilder.nodemap[i]).symtableentry).varoptions)) then
|
not(vo_is_funcret in tparavarsym(tloadnode(dfabuilder.nodemap[i]).symtableentry).varoptions)) then
|
||||||
CheckAndWarn(GetUserCode,tnode(dfabuilder.nodemap[i]));
|
CheckAndWarn(GetUserCode,tnode(dfabuilder.nodemap[i]));
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
if (tnode(dfabuilder.nodemap[i]).nodetype=loadn) and
|
||||||
|
(tloadnode(dfabuilder.nodemap[i]).symtableentry.typ in [staticvarsym,localvarsym]) then
|
||||||
|
tabstractnormalvarsym(tloadnode(dfabuilder.nodemap[i]).symtableentry).noregvarinitneeded:=true
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -220,6 +220,9 @@ interface
|
|||||||
currentregloc : TLocation;
|
currentregloc : TLocation;
|
||||||
{ migrated to a parentfpstruct because of nested access (not written to ppu, because not important and would change interface crc) }
|
{ migrated to a parentfpstruct because of nested access (not written to ppu, because not important and would change interface crc) }
|
||||||
inparentfpstruct : boolean;
|
inparentfpstruct : boolean;
|
||||||
|
{ the variable is not living at entry of the scope, so it does not need to be initialized if it is a reg. var
|
||||||
|
(not written to ppu, because not important and would change interface crc) }
|
||||||
|
noregvarinitneeded : boolean;
|
||||||
constructor create(st:tsymtyp;const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);
|
constructor create(st:tsymtyp;const n : string;vsp:tvarspez;def:tdef;vopts:tvaroptions);
|
||||||
constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile);
|
constructor ppuload(st:tsymtyp;ppufile:tcompilerppufile);
|
||||||
function globalasmsym: boolean;
|
function globalasmsym: boolean;
|
||||||
|
Loading…
Reference in New Issue
Block a user