Browse Source

* ensure that "type SomeName = type reference" is still allowed when function references are disabled
+ added test

Sven/Sarah Barth 1 year ago
parent
commit
3447512e29
2 changed files with 24 additions and 1 deletions
  1. 9 1
      compiler/ptype.pas
  2. 15 0
      tests/tbs/tb0709.pp

+ 9 - 1
compiler/ptype.pas

@@ -1726,7 +1726,15 @@ implementation
          else
            name:='';
          { type a = type ..,; syntax is allowed only with type syms and apparently helpers, see below }
-         if hadtypetoken and ((token<>_ID) or (idtoken=_REFERENCE)) and (token<>_STRING) and (token<>_FILE) then
+         if hadtypetoken and
+             (
+               (token<>_ID) or
+               (
+                 (m_function_references in current_settings.modeswitches) and
+                 (idtoken=_REFERENCE)
+               )
+             ) and
+             (token<>_STRING) and (token<>_FILE) then
            consume(_ID);
          case token of
             _STRING,_FILE:

+ 15 - 0
tests/tbs/tb0709.pp

@@ -0,0 +1,15 @@
+{ %NORUN }
+program tb0709;
+
+{$mode objfpc}
+{ ensure that function reference are disabled }
+{$modeswitch functionreferences-}
+
+type
+  Reference = LongInt;
+
+  TTest = type Reference;
+
+begin
+
+end.