* fix #40381: also check for hints when parsing the parameters of a routine (including open array parameters) or the result type of a function

+ added tests
This commit is contained in:
Sven/Sarah Barth 2023-09-08 15:51:01 +02:00
parent 8fa439e64d
commit 2df57e117b
5 changed files with 132 additions and 0 deletions

View File

@ -400,6 +400,8 @@ implementation
else
stoptions:=[];
single_type(arrayelementdef,stoptions);
if assigned(arrayelementdef.typesym) then
check_hints(arrayelementdef.typesym,arrayelementdef.typesym.symoptions,arrayelementdef.typesym.deprecatedmsg);
tarraydef(hdef).elementdef:=arrayelementdef;
end;
end
@ -469,6 +471,9 @@ implementation
else
hdef:=cformaltype;
if assigned(hdef.typesym) then
check_hints(hdef.typesym,hdef.typesym.symoptions,hdef.typesym.deprecatedmsg);
{ File types are only allowed for var and out parameters }
if (hdef.typ=filedef) and
not(varspez in [vs_out,vs_var]) then
@ -1407,6 +1412,9 @@ implementation
if is_dispinterface(pd.struct) and not is_automatable(pd.returndef) then
Message1(type_e_not_automatable,pd.returndef.typename);
if assigned(pd.returndef.typesym) then
check_hints(pd.returndef.typesym,pd.returndef.typesym.symoptions,pd.returndef.typesym.deprecatedmsg);
if pd.is_generic or pd.is_specialization then
symtablestack.pop(pd.parast);
if popclass>0 then

31
tests/webtbs/tw40381a.pp Normal file
View File

@ -0,0 +1,31 @@
{ %FAIL }
program tw40381a;
{$mode objfpc}
{$warn 5043 error}
type
TFoo = 1..9 deprecated;
TBar = class
//F1: TFoo;
procedure M1(x:TFoo);
end;
{var
a: TFoo;}
{procedure b(x:TFoo);
begin
writeln(x);
end;}
procedure TBar.M1(x: TFoo);
begin
writeln(x);
end;
begin
end.

31
tests/webtbs/tw40381b.pp Normal file
View File

@ -0,0 +1,31 @@
{ %FAIL }
program tw40381b;
{$mode objfpc}
{$warn 5043 error}
type
TFoo = 1..9 deprecated;
TBar = class
//F1: TFoo;
//procedure M1(x:TFoo);
end;
{var
a: TFoo;}
procedure b(x:TFoo);
begin
writeln(x);
end;
{procedure TBar.M1(x: TFoo);
begin
writeln(x);
end;}
begin
end.

31
tests/webtbs/tw40381c.pp Normal file
View File

@ -0,0 +1,31 @@
{ %FAIL }
program tw40381c;
{$mode objfpc}
{$warn 5043 error}
type
TFoo = 1..9 deprecated;
TBar = class
//F1: TFoo;
//procedure M1(x:TFoo);
end;
{var
a: TFoo;}
procedure b(x:array of TFoo);
begin
//writeln(x);
end;
{procedure TBar.M1(x: TFoo);
begin
writeln(x);
end;}
begin
end.

31
tests/webtbs/tw40381d.pp Normal file
View File

@ -0,0 +1,31 @@
{ %FAIL }
program tw40381d;
{$mode objfpc}
{$warn 5043 error}
type
TFoo = 1..9 deprecated;
TBar = class
//F1: TFoo;
function M1:TFoo;
end;
{var
a: TFoo;}
{procedure b(x:TFoo);
begin
writeln(x);
end;}
function TBar.M1:TFoo;
begin
// writeln(x);
end;
begin
end.