瀏覽代碼

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

Sven/Sarah Barth 2 年之前
父節點
當前提交
c1ecfc323a
共有 2 個文件被更改,包括 18 次插入1 次删除
  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;
 
             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

+ 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.