Explorar o código

* when checking whether the current class definition finalises an existing
forward-declared class, only search the current symtable rather than the
entire symtable stack (to prevent finding types in e.g. nested types)

git-svn-id: trunk@17128 -

Jonas Maebe %!s(int64=14) %!d(string=hai) anos
pai
achega
ac283bb237
Modificáronse 3 ficheiros con 28 adicións e 3 borrados
  1. 1 0
      .gitattributes
  2. 4 3
      compiler/pdecl.pas
  3. 23 0
      tests/test/tclass13b.pp

+ 1 - 0
.gitattributes

@@ -9531,6 +9531,7 @@ tests/test/tclass12c.pp svneol=native#text/pascal
 tests/test/tclass12d.pp svneol=native#text/plain
 tests/test/tclass13.pp svneol=native#text/pascal
 tests/test/tclass13a.pp svneol=native#text/plain
+tests/test/tclass13b.pp svneol=native#text/plain
 tests/test/tclass14a.pp svneol=native#text/pascal
 tests/test/tclass14b.pp svneol=native#text/pascal
 tests/test/tclass2.pp svneol=native#text/plain

+ 4 - 3
compiler/pdecl.pas

@@ -397,7 +397,6 @@ implementation
          typename,orgtypename : TIDString;
          newtype  : ttypesym;
          sym      : tsym;
-         srsymtable : TSymtable;
          hdef     : tdef;
          defpos,storetokenpos : tfileposinfo;
          old_block_type : tblock_type;
@@ -462,8 +461,10 @@ implementation
                current_scanner.startrecordtokens(generictokenbuf);
              end;
 
-           { is the type already defined? }
-           searchsym(typename,sym,srsymtable);
+           { is the type already defined? -- must be in the current symtable,
+             not in a nested symtable or one higher up the stack -> don't
+             use searchsym & frinds! }
+           sym:=tsym(symtablestack.top.find(typename));
            newtype:=nil;
            { found a symbol with this name? }
            if assigned(sym) then

+ 23 - 0
tests/test/tclass13b.pp

@@ -0,0 +1,23 @@
+{ %norun }
+
+{$mode delphi}
+
+type
+  tc = class
+    type
+      tforward = class;
+
+      tnested = class
+        type
+          tforward = class;
+
+          tforward = class
+          end;
+      end;
+
+      tforward = class
+      end;
+  end;
+
+begin
+end.