mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-05-28 17:22:37 +02:00
* do not warn about internally generated parameters, resolves #25914
git-svn-id: trunk@29636 -
This commit is contained in:
parent
632f43c490
commit
932b68310e
1
.gitattributes
vendored
1
.gitattributes
vendored
@ -14153,6 +14153,7 @@ 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/tw25914.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw25916a.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw25916b.pp svneol=native#text/pascal
|
||||
tests/webtbs/tw25917.pp svneol=native#text/pascal
|
||||
|
@ -1346,11 +1346,14 @@ implementation
|
||||
begin
|
||||
if DFASetIn(GetUserCode.optinfo^.life,i) then
|
||||
begin
|
||||
{ do not warn about parameters passed by var }
|
||||
{ do not warn for certain parameters: }
|
||||
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
|
||||
{ do not warn about parameters passed by var }
|
||||
(((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
|
||||
not(vo_is_funcret in tparavarsym(tloadnode(dfabuilder.nodemap[i]).symtableentry).varoptions)) or
|
||||
{ do not warn about initialized hidden parameters }
|
||||
((tparavarsym(tloadnode(dfabuilder.nodemap[i]).symtableentry).varoptions*[vo_is_high_para,vo_is_parentfp,vo_is_result,vo_is_self])<>[]))) then
|
||||
CheckAndWarn(GetUserCode,tnode(dfabuilder.nodemap[i]));
|
||||
end
|
||||
else
|
||||
|
42
tests/webtbs/tw25914.pp
Normal file
42
tests/webtbs/tw25914.pp
Normal file
@ -0,0 +1,42 @@
|
||||
{ %opt=-Sh }
|
||||
{$MODE OBJFPC}
|
||||
{$HINTS ON}
|
||||
{$OPTIMIZATION DFA}
|
||||
program test;
|
||||
|
||||
type
|
||||
TTest1 = class
|
||||
FArray: array of record end; // or AnsiString
|
||||
procedure TestMethod();
|
||||
end;
|
||||
|
||||
procedure TTest1.TestMethod();
|
||||
begin
|
||||
SetLength(FArray, 0); // Hint: Local variable "$self" does not seem to be initialized
|
||||
end;
|
||||
|
||||
type
|
||||
TTest2 = class
|
||||
FString: AnsiString; // or dynamic array
|
||||
procedure TestMethod();
|
||||
end;
|
||||
|
||||
procedure TTest2.TestMethod();
|
||||
begin
|
||||
FString := Default(AnsiString); // Hint: Local variable "$self" does not seem to be initialized
|
||||
end;
|
||||
|
||||
type
|
||||
TTest3 = class
|
||||
FValue: Integer;
|
||||
procedure TestMethod(var Value: Integer);
|
||||
end;
|
||||
|
||||
procedure TTest3.TestMethod(var Value: Integer);
|
||||
begin
|
||||
TestMethod(FValue); // Hint: Local variable "$self" does not seem to be initialized
|
||||
Value:=FValue;
|
||||
end;
|
||||
|
||||
begin
|
||||
end.
|
Loading…
Reference in New Issue
Block a user