Browse Source

* Fix bug #31709

git-svn-id: trunk@35950 -
michael 8 years ago
parent
commit
f5b8292b6e
2 changed files with 15 additions and 1 deletions
  1. 3 1
      packages/fcl-passrc/src/pparser.pp
  2. 12 0
      packages/fcl-passrc/tests/tctypeparser.pas

+ 3 - 1
packages/fcl-passrc/src/pparser.pp

@@ -1416,7 +1416,9 @@ begin
       // Always allowed
       // Always allowed
       tkIdentifier:
       tkIdentifier:
         begin
         begin
-        if CurTokenIsIdentifier('reference') then
+        // Bug 31709: PReference = ^Reference;
+        // Checked in Delphi: ^Reference to procedure; is not allowed !!
+        if CurTokenIsIdentifier('reference') and Not (Parent is TPasPointerType) then
           begin
           begin
           CH:=False;
           CH:=False;
           Result:=ParseReferencetoProcedureType(Parent,NamePos,TypeName)
           Result:=ParseReferencetoProcedureType(Parent,NamePos,TypeName)

+ 12 - 0
packages/fcl-passrc/tests/tctypeparser.pas

@@ -161,6 +161,7 @@ type
     Procedure TestReferencePointer;
     Procedure TestReferencePointer;
     Procedure TestInvalidColon;
     Procedure TestInvalidColon;
     Procedure TestTypeHelper;
     Procedure TestTypeHelper;
+    procedure TestPointerReference;
   end;
   end;
 
 
   { TTestRecordTypeParser }
   { TTestRecordTypeParser }
@@ -3314,6 +3315,17 @@ begin
   ParseType('Type Helper for AnsiString end',TPasClassType,'');
   ParseType('Type Helper for AnsiString end',TPasClassType,'');
 end;
 end;
 
 
+procedure TTestTypeParser.TestPointerReference;
+begin
+  Add('Type');
+  Add('  pReference = ^Reference;');
+  Add('  Reference = object');
+  Add('  end;');
+  ParseDeclarations;
+  AssertEquals('type definition count',1,Declarations.Types.Count);
+  AssertEquals('object definition count',1,Declarations.Classes.Count);
+end;
+
 
 
 initialization
 initialization
   RegisterTests([TTestTypeParser,TTestRecordTypeParser,TTestProcedureTypeParser]);
   RegisterTests([TTestTypeParser,TTestRecordTypeParser,TTestProcedureTypeParser]);