Преглед на файлове

compiler: resolve only current typeblock forward declarations when the type block is finished (fixes bug #0018086)

git-svn-id: trunk@16480 -
paul преди 14 години
родител
ревизия
433f18e60c
променени са 3 файла, в които са добавени 29 реда и са изтрити 0 реда
  1. 1 0
      .gitattributes
  2. 9 0
      compiler/pdecl.pas
  3. 19 0
      tests/webtbs/tw18086.pp

+ 1 - 0
.gitattributes

@@ -10773,6 +10773,7 @@ tests/webtbs/tw18013.pp svneol=native#text/plain
 tests/webtbs/tw18075.pp svneol=native#text/pascal
 tests/webtbs/tw18082.pp svneol=native#text/plain
 tests/webtbs/tw18085.pp svneol=native#text/pascal
+tests/webtbs/tw18086.pp svneol=native#text/pascal
 tests/webtbs/tw1820.pp svneol=native#text/plain
 tests/webtbs/tw1825.pp svneol=native#text/plain
 tests/webtbs/tw1850.pp svneol=native#text/plain

+ 9 - 0
compiler/pdecl.pas

@@ -417,6 +417,7 @@ implementation
          hdef     : tdef;
          defpos,storetokenpos : tfileposinfo;
          old_block_type : tblock_type;
+         old_checkforwarddefs: TFPObjectList;
          objecttype : tobjecttyp;
          isgeneric,
          isunique,
@@ -426,6 +427,10 @@ implementation
          vmtbuilder : TVMTBuilder;
       begin
          old_block_type:=block_type;
+         { save unit container of forward declarations -
+           we can be inside nested class type block }
+         old_checkforwarddefs:=current_module.checkforwarddefs;
+         current_module.checkforwarddefs:=TFPObjectList.Create(false);
          block_type:=bt_type;
          repeat
            defpos:=current_tokenpos;
@@ -665,7 +670,11 @@ implementation
            if assigned(generictypelist) then
              generictypelist.free;
          until (token<>_ID)or(in_class and (idtoken in [_PRIVATE,_PROTECTED,_PUBLIC,_PUBLISHED,_STRICT]));
+         { resolve type block forward declarations and restore a unit
+           container for them }
          resolve_forward_types;
+         current_module.checkforwarddefs.free;
+         current_module.checkforwarddefs:=old_checkforwarddefs;
          block_type:=old_block_type;
       end;
 

+ 19 - 0
tests/webtbs/tw18086.pp

@@ -0,0 +1,19 @@
+program tw18086;
+
+{$mode delphi}
+
+type
+  TFoo1 = class; //Error: Type "TFoo1" is not completely defined
+
+  TFoo2 = class //it compiles if TFoo2 is removed
+  type
+    TFoo3 = class
+    end;
+  end;
+
+  TFoo1 = class
+  end;
+
+begin
+end.
+