diff --git a/.gitattributes b/.gitattributes index 9449105dc7..711268cf11 100644 --- a/.gitattributes +++ b/.gitattributes @@ -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 diff --git a/compiler/psub.pas b/compiler/psub.pas index 9cf5e3ac15..308e7c7c00 100644 --- a/compiler/psub.pas +++ b/compiler/psub.pas @@ -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; diff --git a/tests/webtbs/tw25916a.pp b/tests/webtbs/tw25916a.pp new file mode 100644 index 0000000000..6d65556d14 --- /dev/null +++ b/tests/webtbs/tw25916a.pp @@ -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. diff --git a/tests/webtbs/tw25916b.pp b/tests/webtbs/tw25916b.pp new file mode 100644 index 0000000000..907c59e876 --- /dev/null +++ b/tests/webtbs/tw25916b.pp @@ -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.