Browse Source

* ensure that a procvar (especially a "REFERENCE TO") begins either with FUNCTION or PROCEDURE
+ added test

Sven/Sarah Barth 2 years ago
parent
commit
c1ecfc323a
2 changed files with 18 additions and 1 deletions
  1. 4 1
      compiler/ptype.pas
  2. 14 0
      tests/tbf/tb0297.pp

+ 4 - 1
compiler/ptype.pas

@@ -1584,7 +1584,10 @@ implementation
             olddef:=nil;
             olddef:=nil;
 
 
             is_func:=(token=_FUNCTION);
             is_func:=(token=_FUNCTION);
-            consume(token);
+            if token in [_FUNCTION,_PROCEDURE] then
+              consume(token)
+            else
+              consume(_FUNCTION);
             pd:=cprocvardef.create(normal_function_level,doregister);
             pd:=cprocvardef.create(normal_function_level,doregister);
 
 
             if assigned(sym) then
             if assigned(sym) then

+ 14 - 0
tests/tbf/tb0297.pp

@@ -0,0 +1,14 @@
+{ %FAIL }
+
+program tb0297;
+
+{$mode objfpc}
+{$modeswitch functionreferences}
+
+type
+  TTestProc = procedure;
+  TTestProcRef = reference to TTestProc;
+
+begin
+
+end.