Browse Source

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

git-svn-id: branches/paul/extended_records@16516 -
paul 14 years ago
parent
commit
d7c8d9e620
6 changed files with 87 additions and 1 deletions
  1. 4 0
      .gitattributes
  2. 1 1
      compiler/pexpr.pas
  3. 18 0
      tests/test/terecs1.pp
  4. 19 0
      tests/test/terecs2.pp
  5. 21 0
      tests/test/terecs3.pp
  6. 24 0
      tests/test/terecs_u1.pp

+ 4 - 0
.gitattributes

@@ -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

+ 1 - 1
compiler/pexpr.pas

@@ -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 - 0
tests/test/terecs1.pp

@@ -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 - 0
tests/test/terecs2.pp

@@ -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 - 0
tests/test/terecs3.pp

@@ -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 - 0
tests/test/terecs_u1.pp

@@ -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.
+