Browse Source

* do not warn on anonymous functions without captured variables about being not used, resolves #39853

florian 3 years ago
parent
commit
6c47f8f4d7
2 changed files with 10 additions and 0 deletions
  1. 2 0
      compiler/pdecsub.pas
  2. 8 0
      tests/webtbs/tw39853.pp

+ 2 - 0
compiler/pdecsub.pas

@@ -1127,6 +1127,8 @@ implementation
                   aprocsym:=cprocsym.create('$'+lower(sp))
                   aprocsym:=cprocsym.create('$'+lower(sp))
                 else
                 else
                   aprocsym:=cprocsym.create(orgsp);
                   aprocsym:=cprocsym.create(orgsp);
+                if ppf_anonymous in flags then
+                  include(aprocsym.symoptions,sp_internal);
                 if addgendummy then
                 if addgendummy then
                   include(aprocsym.symoptions,sp_generic_dummy);
                   include(aprocsym.symoptions,sp_generic_dummy);
                 symtablestack.top.insertsym(aprocsym);
                 symtablestack.top.insertsym(aprocsym);

+ 8 - 0
tests/webtbs/tw39853.pp

@@ -0,0 +1,8 @@
+{ %opt=-vh -Sewh }
+{$modeswitch anonymousfunctions}
+var
+	p: procedure(const s: string);
+begin
+	p := procedure(const s: string) begin writeln(s); end;
+	p('test');
+end.