compiler: don't allow local or anonymous records to have types (the second part of issue #0019099)

git-svn-id: trunk@17336 -
This commit is contained in:
paul 2011-04-18 06:10:56 +00:00
parent 550ad700c3
commit f904f41664
8 changed files with 422 additions and 375 deletions

2
.gitattributes vendored
View File

@ -9696,6 +9696,8 @@ tests/test/tenumerators1.pp svneol=native#text/pascal
tests/test/terecs1.pp svneol=native#text/pascal
tests/test/terecs10.pp svneol=native#text/pascal
tests/test/terecs11.pp svneol=native#text/pascal
tests/test/terecs12.pp svneol=native#text/pascal
tests/test/terecs13.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

@ -1382,6 +1382,9 @@ parser_e_no_class_constructor_in_helpers=03308_E_Class constructors aren't allow
parser_e_inherited_not_in_record=03309_E_The use of "inherited" is not allowed in a record
% As records don't suppport inheritance the use of "inherited" is prohibited for
% these as well as for record helpers (in mode "Delphi" only).
parser_e_no_types_in_local_anonymous_records=03310_E_Type declarations are not allowed in local or anonymous records
% Records with types must be defined globally. Types cannot be defined inside records which are defined in a
% procedure or function or in anonymous records.
% \end{description}
# Type Checking
#

View File

@ -398,6 +398,7 @@ const
parser_e_not_allowed_in_helper=03307;
parser_e_no_class_constructor_in_helpers=03308;
parser_e_inherited_not_in_record=03309;
parser_e_no_types_in_local_anonymous_records=03310;
type_e_mismatch=04000;
type_e_incompatible_types=04001;
type_e_not_equal_types=04002;
@ -891,9 +892,9 @@ const
option_info=11024;
option_help_pages=11025;
MsgTxtSize = 59257;
MsgTxtSize = 59329;
MsgIdxMax : array[1..20] of longint=(
24,88,310,103,84,54,111,22,202,63,
24,88,311,103,84,54,111,22,202,63,
49,20,1,1,1,1,1,1,1,1
);

File diff suppressed because it is too large Load Diff

View File

@ -491,7 +491,6 @@ implementation
srsymtable : TSymtable;
s,sorg : TIDString;
t : ttoken;
structdef : tabstractrecorddef;
begin
s:=pattern;
sorg:=orgpattern;
@ -684,6 +683,11 @@ implementation
begin
consume(_TYPE);
member_blocktype:=bt_type;
{ local and anonymous records can not have inner types. skip top record symtable }
if (current_structdef.objname^='') or
not(symtablestack.stack^.next^.symtable.symtabletype in [globalsymtable,staticsymtable,objectsymtable,recordsymtable]) then
Message(parser_e_no_types_in_local_anonymous_records);
end;
_VAR :
begin

View File

@ -1,4 +1,4 @@
program texrec1;
program terecs11;
{$ifdef fpc}
{$mode delphi}

19
tests/test/terecs12.pp Normal file
View File

@ -0,0 +1,19 @@
{ %FAIL }
{ %NORUN }
program terecs12;
{$ifdef fpc}
{$mode delphi}
{$endif}
procedure Test;
type
TRecord = record
private type
TTestRange = 0..42;
end;
begin
end;
begin
end.

16
tests/test/terecs13.pp Normal file
View File

@ -0,0 +1,16 @@
{ %FAIL }
{ %NORUN }
program terecs13;
{$ifdef fpc}
{$mode delphi}
{$endif}
var
R: record
private type
TTestRange = 0..42;
end;
begin
end.