From c1ecfc323ae3c259aa3c085dc7bdb2abb5b0f3e7 Mon Sep 17 00:00:00 2001 From: Sven/Sarah Barth Date: Wed, 15 Mar 2023 23:35:30 +0100 Subject: [PATCH] * ensure that a procvar (especially a "REFERENCE TO") begins either with FUNCTION or PROCEDURE + added test --- compiler/ptype.pas | 5 ++++- tests/tbf/tb0297.pp | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 tests/tbf/tb0297.pp diff --git a/compiler/ptype.pas b/compiler/ptype.pas index 6ddc447367..097d7a73b5 100644 --- a/compiler/ptype.pas +++ b/compiler/ptype.pas @@ -1584,7 +1584,10 @@ implementation olddef:=nil; is_func:=(token=_FUNCTION); - consume(token); + if token in [_FUNCTION,_PROCEDURE] then + consume(token) + else + consume(_FUNCTION); pd:=cprocvardef.create(normal_function_level,doregister); if assigned(sym) then diff --git a/tests/tbf/tb0297.pp b/tests/tbf/tb0297.pp new file mode 100644 index 0000000000..d86838be2b --- /dev/null +++ b/tests/tbf/tb0297.pp @@ -0,0 +1,14 @@ +{ %FAIL } + +program tb0297; + +{$mode objfpc} +{$modeswitch functionreferences} + +type + TTestProc = procedure; + TTestProcRef = reference to TTestProc; + +begin + +end.