compiler: allow access other record symbols than fields, first extended records tests

git-svn-id: branches/paul/extended_records@16516 -
This commit is contained in:
paul 2010-12-07 09:53:57 +00:00
parent 902a78eec1
commit d7c8d9e620
6 changed files with 87 additions and 1 deletions

4
.gitattributes vendored
View File

@ -9203,6 +9203,10 @@ tests/test/tenum3.pp svneol=native#text/plain
tests/test/tenum4.pp svneol=native#text/plain
tests/test/tenum5.pp svneol=native#text/plain
tests/test/tenumerators1.pp svneol=native#text/pascal
tests/test/terecs1.pp svneol=native#text/pascal
tests/test/terecs2.pp svneol=native#text/pascal
tests/test/terecs3.pp svneol=native#text/pascal
tests/test/terecs_u1.pp svneol=native#text/pascal
tests/test/testcmem.pp svneol=native#text/plain
tests/test/testda1.pp svneol=native#text/plain
tests/test/testfpuc.pp svneol=native#text/plain

View File

@ -2061,7 +2061,7 @@ implementation
begin
structh:=tabstractrecorddef(p1.resultdef);
searchsym_in_record(structh,pattern,srsym,srsymtable);
if assigned(srsym) and (srsym.typ=fieldvarsym) then
if assigned(srsym) then
begin
check_hints(srsym,srsym.symoptions,srsym.deprecatedmsg);
consume(_ID);

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

@ -0,0 +1,18 @@
{ %fail}
{ %norun}
program terecs1;
{$mode delphi}
{$apptype console}
uses
terecs_u1;
var
F: TFoo;
begin
// we can't access private fields
F.F1 := 0;
F.F2 := 1;
end.

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

@ -0,0 +1,19 @@
{ %fail}
{ %norun}
program terecs2;
{$mode delphi}
type
TFoo = record
private
F1: Integer;
F2: Byte;
public
F3: Integer;
F4: Byte;
published // record can't have published fields
F5: String;
end;
begin
end.

21
tests/test/terecs3.pp Normal file
View File

@ -0,0 +1,21 @@
program terecs3;
{$mode delphi}
{$apptype console}
uses
terecs_u1;
var
F: TFoo;
begin
F.F3 := 0;
F.F4 := 1;
if F.F3 <> 0 then
halt(1);
if F.F4 <> 1 then
halt(2);
if F.C <> 1 then
halt(3);
WriteLn('ok');
end.

24
tests/test/terecs_u1.pp Normal file
View File

@ -0,0 +1,24 @@
{ %norun }
unit terecs_u1;
{$mode delphi}
interface
type
TFoo = record
private
F1: Integer;
F2: Byte;
public
const
C = 1;
var
F3: Integer;
F4: Byte;
end;
implementation
end.