Przeglądaj źródła

compiler: support *sealed* and *abstract* for objects (issue #0016174)

git-svn-id: trunk@15105 -
paul 15 lat temu
rodzic
commit
8a0028a62e
4 zmienionych plików z 39 dodań i 2 usunięć
  1. 2 0
      .gitattributes
  2. 5 2
      compiler/pdecobj.pas
  3. 17 0
      tests/test/tsealed5.pp
  4. 15 0
      tests/test/tsealed6.pp

+ 2 - 0
.gitattributes

@@ -9286,6 +9286,8 @@ tests/test/tsealed1.pp svneol=native#text/pascal
 tests/test/tsealed2.pp svneol=native#text/pascal
 tests/test/tsealed3.pp svneol=native#text/pascal
 tests/test/tsealed4.pp svneol=native#text/pascal
+tests/test/tsealed5.pp svneol=native#text/pascal
+tests/test/tsealed6.pp svneol=native#text/pascal
 tests/test/tsel1.pp svneol=native#text/plain
 tests/test/tsel2.pp svneol=native#text/plain
 tests/test/tset1.pp svneol=native#text/plain

+ 5 - 2
compiler/pdecobj.pas

@@ -284,7 +284,7 @@ implementation
 
     procedure parse_object_options;
       begin
-        if current_objectdef.objecttype = odt_class then
+        if current_objectdef.objecttype in [odt_object,odt_class] then
           begin
             while true do
               begin
@@ -389,7 +389,10 @@ implementation
                      end;
                    odt_object:
                      if not(is_object(childof)) then
-                       Message(parser_e_mix_of_classes_and_objects);
+                       Message(parser_e_mix_of_classes_and_objects)
+                     else
+                       if oo_is_sealed in childof.objectoptions then
+                         Message1(parser_e_sealed_descendant,childof.typename);
                    odt_dispinterface:
                      Message(parser_e_dispinterface_cant_have_parent);
                 end;

+ 17 - 0
tests/test/tsealed5.pp

@@ -0,0 +1,17 @@
+{ %fail }
+{$ifdef fpc}
+{$mode objfpc}
+{$endif}
+
+type
+  TSealedObject = object sealed
+  public
+  end;
+
+  TSealedDesdentantObject = object(TSealedObject)
+  public
+  end;
+
+begin
+end.
+

+ 15 - 0
tests/test/tsealed6.pp

@@ -0,0 +1,15 @@
+{$ifdef fpc}
+{$mode objfpc}
+{$endif}
+
+type
+  TAbstractObject = object abstract abstract abstract
+  public
+  end;
+
+  TSealedObject = object sealed sealed sealed
+  public
+  end;
+begin
+end.
+