From 22a4cc66ec7dc79315a0f63d27d2ab003f7777f1 Mon Sep 17 00:00:00 2001 From: Sven/Sarah Barth Date: Thu, 21 Apr 2022 22:21:04 +0200 Subject: [PATCH] * fix #39675: consider the symbols for unnamed parameters as used so that there won't be unnecessary hints about them + added test --- compiler/pgenutil.pas | 2 ++ tests/webtbs/tw39675.pp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 tests/webtbs/tw39675.pp diff --git a/compiler/pgenutil.pas b/compiler/pgenutil.pas index 48ddf1a8f8..2dda31dfe7 100644 --- a/compiler/pgenutil.pas +++ b/compiler/pgenutil.pas @@ -759,6 +759,8 @@ uses begin newtype:=ctypesym.create(def.fullownerhierarchyname(false)+typName[def.typ]+'$'+def.unique_id_str,def); newtype.owner:=def.owner; + { ensure that there's no warning } + newtype.refs:=1; end; if not assigned(newtype) then internalerror(2021020904); diff --git a/tests/webtbs/tw39675.pp b/tests/webtbs/tw39675.pp new file mode 100644 index 0000000000..3803897fff --- /dev/null +++ b/tests/webtbs/tw39675.pp @@ -0,0 +1,36 @@ +{ %NORUN } + +program tw39675; + +{ "private type xyz never used" } +{$warn 5071 error} + +{$mode delphi} +{$ModeSwitch implicitfunctionspecialization} + +type + TWingFunc = function(aArg: T): T of object; + TBird = class + public + function Fly(aFunc: TWingFunc; ArgB: T): T; + function Flap(s: string): string; + end; + +{ TBird } + +function TBird.Fly(aFunc: TWingFunc; ArgB: T): T; +begin + Result:=aFunc(ArgB); +end; + +function TBird.Flap(s: string): string; +begin + Result:='Flap'+s; +end; + +var + Bird: TBird; +begin + Bird:=TBird.Create; + writeln(Bird.Fly(Bird.Flap,'Foo')); +end.