From 6c47f8f4d79d3cd571e5d6526dec0791d2b2c8f8 Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 29 Jul 2022 21:46:07 +0200 Subject: [PATCH] * do not warn on anonymous functions without captured variables about being not used, resolves #39853 --- compiler/pdecsub.pas | 2 ++ tests/webtbs/tw39853.pp | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 tests/webtbs/tw39853.pp diff --git a/compiler/pdecsub.pas b/compiler/pdecsub.pas index 57a245aef8..b8ee67e543 100644 --- a/compiler/pdecsub.pas +++ b/compiler/pdecsub.pas @@ -1127,6 +1127,8 @@ implementation aprocsym:=cprocsym.create('$'+lower(sp)) else aprocsym:=cprocsym.create(orgsp); + if ppf_anonymous in flags then + include(aprocsym.symoptions,sp_internal); if addgendummy then include(aprocsym.symoptions,sp_generic_dummy); symtablestack.top.insertsym(aprocsym); diff --git a/tests/webtbs/tw39853.pp b/tests/webtbs/tw39853.pp new file mode 100644 index 0000000000..d4597a075b --- /dev/null +++ b/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.