Disallow "protected" and "strict protected" in extended records (Delphi compatible).

ptype.pas, parse_record_members:
  * write an error message if "protected" or "strict protected" is encountered
msg/errore.msg:
  + add an error message for disallowed "things" in records

+ added test
* adjusted test (note: according to the bug report this test did not originally have the "protected" section, but it was added by Paul before commiting)

git-svn-id: trunk@23596 -
This commit is contained in:
svenbarth 2013-02-11 18:46:47 +00:00
parent 7dc1814b7a
commit 489e038379
7 changed files with 443 additions and 410 deletions

1
.gitattributes vendored
View File

@ -10820,6 +10820,7 @@ tests/test/terecs17.pp svneol=native#text/pascal
tests/test/terecs17a.pp svneol=native#text/pascal
tests/test/terecs18.pp svneol=native#text/pascal
tests/test/terecs18a.pp svneol=native#text/pascal
tests/test/terecs19.pp svneol=native#text/pascal
tests/test/terecs2.pp svneol=native#text/pascal
tests/test/terecs3.pp svneol=native#text/pascal
tests/test/terecs4.pp svneol=native#text/pascal

View File

@ -392,7 +392,7 @@ scan_w_setpeoptflags_not_support=02092_W_SETPEOPTFLAGS is not supported by the t
#
# Parser
#
# 03331 is the last used one
# 03332 is the last used one
#
% \section{Parser messages}
% This section lists all parser messages. The parser takes care of the
@ -1483,6 +1483,11 @@ parser_e_no_properties_in_local_anonymous_records=03330_E_Property declarations
parser_e_no_class_in_local_anonymous_records=03331_E_Class memeber declarations are not allowed in local or anonymous records
% Records with class members must be defined globally. Class members cannot be defined inside records which are defined in a
% procedure or function or in anonymous records.
parser_e_not_allowed_in_record=03332_E_Visibility section "$1" not allowed in records
% The visibility sections \var(protected) and \var(strict protected) are only
% useful together with inheritance. Since records do not support that they are
% forbidden.
%
%
% \end{description}
%

View File

@ -427,6 +427,7 @@ const
parser_e_no_methods_in_local_anonymous_records=03329;
parser_e_no_properties_in_local_anonymous_records=03330;
parser_e_no_class_in_local_anonymous_records=03331;
parser_e_not_allowed_in_record=03332;
type_e_mismatch=04000;
type_e_incompatible_types=04001;
type_e_not_equal_types=04002;
@ -970,9 +971,9 @@ const
option_info=11024;
option_help_pages=11025;
MsgTxtSize = 68689;
MsgTxtSize = 68744;
MsgIdxMax : array[1..20] of longint=(
26,93,332,121,88,56,126,27,202,63,
26,93,333,121,88,56,126,27,202,63,
54,20,1,1,1,1,1,1,1,1
);

File diff suppressed because it is too large Load Diff

View File

@ -586,6 +586,7 @@ implementation
end;
_PROTECTED :
begin
Message1(parser_e_not_allowed_in_record,tokeninfo^[_PROTECTED].str);
consume(_PROTECTED);
current_structdef.symtable.currentvisibility:=vis_protected;
include(current_structdef.objectoptions,oo_has_protected);
@ -627,6 +628,8 @@ implementation
end;
_PROTECTED:
begin
{ "strict protected" is not allowed for records }
Message1(parser_e_not_allowed_in_record,tokeninfo^[_STRICT].str+' '+tokeninfo^[_PROTECTED].str);
consume(_PROTECTED);
current_structdef.symtable.currentvisibility:=vis_strictprotected;
include(current_structdef.objectoptions,oo_has_strictprotected);

18
tests/test/terecs19.pp Normal file
View File

@ -0,0 +1,18 @@
{ %FAIL }
program terecs19;
{$mode objfpc}
{$modeswitch advancedrecords}
type
TRecord = record
strict protected
f1: LongInt;
protected
f2: LongInt;
end;
begin
end.

View File

@ -10,7 +10,7 @@ type
TFoo3 = record
private
b, c: integer;
protected
strict private
a: integer;
public
function GetFoo2: integer;