瀏覽代碼

* fix type parsing in records

peter 22 年之前
父節點
當前提交
3b771392a1
共有 1 個文件被更改,包括 24 次插入2 次删除
  1. 24 2
      compiler/pdecvar.pas

+ 24 - 2
compiler/pdecvar.pas

@@ -133,6 +133,7 @@ implementation
          pt : tnode;
          pt : tnode;
          vs,vs2    : tvarsym;
          vs,vs2    : tvarsym;
          srsym : tsym;
          srsym : tsym;
+         oldsymtablestack,
          srsymtable : tsymtable;
          srsymtable : tsymtable;
          unionsymtable : trecordsymtable;
          unionsymtable : trecordsymtable;
          offset : longint;
          offset : longint;
@@ -179,7 +180,17 @@ implementation
              { this is needed for Delphi mode at least
              { this is needed for Delphi mode at least
                but should be OK for all modes !! (PM) }
                but should be OK for all modes !! (PM) }
              ignore_equal:=true;
              ignore_equal:=true;
-             read_type(tt,'');
+             if is_record or is_object then
+              begin
+                { for records, don't search the recordsymtable for
+                  the symbols of the types }
+                oldsymtablestack:=symtablestack;
+                symtablestack:=symtablestack.next;
+                read_type(tt,'');
+                symtablestack:=oldsymtablestack;
+              end
+             else
+              read_type(tt,'');
              { types that use init/final are not allowed in variant parts, but
              { types that use init/final are not allowed in variant parts, but
                classes are allowed }
                classes are allowed }
              if (variantrecordlevel>0) and
              if (variantrecordlevel>0) and
@@ -495,7 +506,12 @@ implementation
               { may be only a type: }
               { may be only a type: }
               if assigned(srsym) and (srsym.typ in [typesym,unitsym]) then
               if assigned(srsym) and (srsym.typ in [typesym,unitsym]) then
                begin
                begin
+                 { for records, don't search the recordsymtable for
+                   the symbols of the types }
+                 oldsymtablestack:=symtablestack;
+                 symtablestack:=symtablestack.next;
                  read_type(casetype,'');
                  read_type(casetype,'');
+                 symtablestack:=oldsymtablestack;
                end
                end
               else
               else
                 begin
                 begin
@@ -503,7 +519,10 @@ implementation
                   consume(_COLON);
                   consume(_COLON);
                   { for records, don't search the recordsymtable for
                   { for records, don't search the recordsymtable for
                     the symbols of the types }
                     the symbols of the types }
+                  oldsymtablestack:=symtablestack;
+                  symtablestack:=symtablestack.next;
                   read_type(casetype,'');
                   read_type(casetype,'');
+                  symtablestack:=oldsymtablestack;
                   vs:=tvarsym.create(sorg,vs_value,casetype);
                   vs:=tvarsym.create(sorg,vs_value,casetype);
                   tabstractrecordsymtable(symtablestack).insertfield(vs,true);
                   tabstractrecordsymtable(symtablestack).insertfield(vs,true);
                 end;
                 end;
@@ -598,7 +617,10 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.52  2003-10-01 19:05:33  peter
+  Revision 1.53  2003-10-02 15:12:07  peter
+    * fix type parsing in records
+
+  Revision 1.52  2003/10/01 19:05:33  peter
     * searchsym_type to search for type definitions. It ignores
     * searchsym_type to search for type definitions. It ignores
       records,objects and parameters
       records,objects and parameters