Browse Source

* Objects can also be abstract in FPC

Michaël Van Canneyt 3 years ago
parent
commit
f4da533440

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

@@ -7641,7 +7641,7 @@ var
   s: String;
   Expr: TPasExpr;
 begin
-  if (CurToken=tkIdentifier) and (AType.ObjKind=okClass) then
+  if (CurToken=tkIdentifier) and (AType.ObjKind in [okClass,okObject]) then
     begin
     s := LowerCase(CurTokenString);
     if (s = 'sealed') or (s = 'abstract') then

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

@@ -170,6 +170,7 @@ type
     procedure TestPointerReference;
     Procedure TestPointerKeyWord;
     Procedure TestPointerFile;
+    Procedure TestAbstractObject;
   end;
 
   { TTestRecordTypeParser }
@@ -3814,6 +3815,19 @@ begin
   AssertEquals('object definition count',1,Declarations.Types.Count);
 end;
 
+procedure TTestTypeParser.TestAbstractObject;
+
+begin
+  Add('Type');
+  Add('  Reference = object abstract');
+  Add('   x : integer;');
+  Add('  end;');
+  ParseDeclarations;
+  AssertEquals('object definition count',1,Declarations.Classes.Count);
+  AssertEquals('object is abstract',True,TPasClassType(Declarations.Classes[0]).IsAbstract);
+  AssertEquals('object is object',True,TPasClassType(Declarations.Classes[0]).ObjKind=okObject);
+end;
+
 
 
 initialization

+ 3 - 3
packages/fcl-passrc/tests/testpassrc.lpi

@@ -24,13 +24,13 @@
     </PublishOptions>
     <RunParams>
       <local>
-        <CommandLineParams Value="--suite=TTestLabelParser"/>
+        <CommandLineParams Value="--suite=TTestTypeParser.TestAbstractObject"/>
       </local>
       <FormatVersion Value="2"/>
       <Modes Count="1">
         <Mode0 Name="default">
           <local>
-            <CommandLineParams Value="--suite=TTestLabelParser"/>
+            <CommandLineParams Value="--suite=TTestTypeParser.TestAbstractObject"/>
           </local>
         </Mode0>
       </Modes>
@@ -94,7 +94,7 @@
         <IsPartOfProject Value="True"/>
       </Unit12>
       <Unit13>
-        <Filename Value="tcgenerics.pp"/>
+        <Filename Value="tcgenerics.pas"/>
         <IsPartOfProject Value="True"/>
       </Unit13>
       <Unit14>