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

git-svn-id: trunk@16480 -
This commit is contained in:
paul 2010-11-30 00:02:06 +00:00
parent 01a7da9817
commit 433f18e60c
3 changed files with 29 additions and 0 deletions

1
.gitattributes vendored
View File

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

View File

@ -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
tests/webtbs/tw18086.pp Normal file
View File

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