* do not issue a hint about uninitialized var-parameters, resolves #25916

git-svn-id: trunk@29289 -
This commit is contained in:
florian 2014-12-14 17:54:37 +00:00
parent 21dcedb18e
commit f1eb00a450
4 changed files with 35 additions and 1 deletions

2
.gitattributes vendored
View File

@ -14103,6 +14103,8 @@ tests/webtbs/tw25869.pp svneol=native#text/plain
tests/webtbs/tw2588.pp svneol=native#text/plain
tests/webtbs/tw2589.pp svneol=native#text/plain
tests/webtbs/tw25895.pp svneol=native#text/pascal
tests/webtbs/tw25916a.pp svneol=native#text/pascal
tests/webtbs/tw25916b.pp svneol=native#text/pascal
tests/webtbs/tw25929.pp svneol=native#text/pascal
tests/webtbs/tw25930.pp svneol=native#text/plain
tests/webtbs/tw25931.pp -text svneol=native#text/plain

View File

@ -1334,7 +1334,12 @@ implementation
{ iterate through life info of the first node }
for i:=0 to dfabuilder.nodemap.count-1 do
begin
if DFASetIn(GetUserCode.optinfo^.life,i) then
if DFASetIn(GetUserCode.optinfo^.life,i) and
{ do not warn about parameters passed by var }
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
{ function result is passed by var but it must be initialized }
not(vo_is_funcret in tparavarsym(tloadnode(dfabuilder.nodemap[i]).symtableentry).varoptions)) then
CheckAndWarn(GetUserCode,tnode(dfabuilder.nodemap[i]));
end;
end;

14
tests/webtbs/tw25916a.pp Normal file
View File

@ -0,0 +1,14 @@
{ %OPT=-Sh}
{$MODE OBJFPC}
{$OPTIMIZATION DFA}
{$HINTS ON}
program test;
procedure TestText(var F: Text);
begin
Writeln(F, 'Test'); // Hint: Local variable "F" does not seem to be initialized
end;
begin
TestText(Output);
end.

13
tests/webtbs/tw25916b.pp Normal file
View File

@ -0,0 +1,13 @@
{ %OPT=-Sh}
{$MODE OBJFPC}
{$OPTIMIZATION DFA}
{$HINTS ON}
program test;
procedure TestText(var F: longint);
begin
TestText(F);
end;
begin
end.