diff --git a/.gitattributes b/.gitattributes index 369175b228..e7051c0d40 100644 --- a/.gitattributes +++ b/.gitattributes @@ -9158,6 +9158,7 @@ tests/test/tclass1.pp svneol=native#text/plain tests/test/tclass10.pp svneol=native#text/pascal tests/test/tclass10a.pp svneol=native#text/pascal tests/test/tclass10b.pp svneol=native#text/pascal +tests/test/tclass10c.pp svneol=native#text/pascal tests/test/tclass11a.pp svneol=native#text/pascal tests/test/tclass11b.pp svneol=native#text/pascal tests/test/tclass12a.pp svneol=native#text/pascal diff --git a/compiler/pdecobj.pas b/compiler/pdecobj.pas index 349cef87d0..be7db2acca 100644 --- a/compiler/pdecobj.pas +++ b/compiler/pdecobj.pas @@ -650,6 +650,8 @@ implementation current_objectdef.symtable.currentvisibility:=vis_private; include(current_objectdef.objectoptions,oo_has_private); fields_allowed:=true; + is_classdef:=false; + classfields:=false; object_member_blocktype:=bt_general; end; _PROTECTED : @@ -661,6 +663,8 @@ implementation current_objectdef.symtable.currentvisibility:=vis_protected; include(current_objectdef.objectoptions,oo_has_protected); fields_allowed:=true; + is_classdef:=false; + classfields:=false; object_member_blocktype:=bt_general; end; _PUBLIC : @@ -671,6 +675,8 @@ implementation consume(_PUBLIC); current_objectdef.symtable.currentvisibility:=vis_public; fields_allowed:=true; + is_classdef:=false; + classfields:=false; object_member_blocktype:=bt_general; end; _PUBLISHED : @@ -687,6 +693,8 @@ implementation consume(_PUBLISHED); current_objectdef.symtable.currentvisibility:=vis_published; fields_allowed:=true; + is_classdef:=false; + classfields:=false; object_member_blocktype:=bt_general; end; _STRICT : @@ -717,6 +725,8 @@ implementation else message(parser_e_protected_or_private_expected); fields_allowed:=true; + is_classdef:=false; + classfields:=false; object_member_blocktype:=bt_general; end else diff --git a/tests/test/tclass10c.pp b/tests/test/tclass10c.pp new file mode 100644 index 0000000000..2286f04f27 --- /dev/null +++ b/tests/test/tclass10c.pp @@ -0,0 +1,21 @@ +program tclass10c; +{$ifdef fpc} + {$mode delphi} +{$endif} + +// check that "protected" or any other section resets the section type to accept regular fields + +type + Tfoo=class + private + class var + f1: Integer; + protected + f2: Integer; + public + class property pf1: Integer read f1; + property pf2: Integer read f2; + end; + +begin +end.