From 8a0028a62e712d0f3f7e40199034474b570689cb Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 1 Apr 2010 14:36:33 +0000 Subject: [PATCH] compiler: support *sealed* and *abstract* for objects (issue #0016174) git-svn-id: trunk@15105 - --- .gitattributes | 2 ++ compiler/pdecobj.pas | 7 +++++-- tests/test/tsealed5.pp | 17 +++++++++++++++++ tests/test/tsealed6.pp | 15 +++++++++++++++ 4 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 tests/test/tsealed5.pp create mode 100644 tests/test/tsealed6.pp diff --git a/.gitattributes b/.gitattributes index 1ae8c878e9..bebb94f127 100644 --- a/.gitattributes +++ b/.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 diff --git a/compiler/pdecobj.pas b/compiler/pdecobj.pas index c70414ffa8..7af4377ef1 100644 --- a/compiler/pdecobj.pas +++ b/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; diff --git a/tests/test/tsealed5.pp b/tests/test/tsealed5.pp new file mode 100644 index 0000000000..f3a7952331 --- /dev/null +++ b/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. + diff --git a/tests/test/tsealed6.pp b/tests/test/tsealed6.pp new file mode 100644 index 0000000000..91a73066fd --- /dev/null +++ b/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. +