Browse Source

* fix #39675: consider the symbols for unnamed parameters as used so that there won't be unnecessary hints about them
+ added test

Sven/Sarah Barth 3 years ago
parent
commit
22a4cc66ec
2 changed files with 38 additions and 0 deletions
  1. 2 0
      compiler/pgenutil.pas
  2. 36 0
      tests/webtbs/tw39675.pp

+ 2 - 0
compiler/pgenutil.pas

@@ -759,6 +759,8 @@ uses
             begin
             begin
               newtype:=ctypesym.create(def.fullownerhierarchyname(false)+typName[def.typ]+'$'+def.unique_id_str,def);
               newtype:=ctypesym.create(def.fullownerhierarchyname(false)+typName[def.typ]+'$'+def.unique_id_str,def);
               newtype.owner:=def.owner;
               newtype.owner:=def.owner;
+              { ensure that there's no warning }
+              newtype.refs:=1;
             end;
             end;
           if not assigned(newtype) then
           if not assigned(newtype) then
             internalerror(2021020904);
             internalerror(2021020904);

+ 36 - 0
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<T> = function(aArg: T): T of object;
+  TBird = class
+  public
+    function Fly<T>(aFunc: TWingFunc<T>; ArgB: T): T;
+    function Flap(s: string): string;
+  end;
+
+{ TBird }
+
+function TBird.Fly<T>(aFunc: TWingFunc<T>; 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.