From a8deeaa16899fc0546cd4b005b7965e2a63aaa96 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 17 Nov 2010 05:51:54 +0000 Subject: [PATCH] compiler: fix search of outer class type inside inner type declarations (bug #0017945) git-svn-id: trunk@16352 - --- .gitattributes | 1 + compiler/ptype.pas | 27 +++++++++++++++++---------- tests/webtbs/tw17945.pp | 14 ++++++++++++++ 3 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 tests/webtbs/tw17945.pp diff --git a/.gitattributes b/.gitattributes index 877857e2c1..4eee4ed8b9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -10751,6 +10751,7 @@ tests/webtbs/tw17907/unit2/unit0002.pas svneol=native#text/plain tests/webtbs/tw1792.pp svneol=native#text/plain tests/webtbs/tw17928.pp svneol=native#text/plain tests/webtbs/tw1792a.pp svneol=native#text/plain +tests/webtbs/tw17945.pp svneol=native#text/pascal tests/webtbs/tw17950.pp svneol=native#text/pascal tests/webtbs/tw1798.pp svneol=native#text/plain tests/webtbs/tw1820.pp svneol=native#text/plain diff --git a/compiler/ptype.pas b/compiler/ptype.pas index 28cf9d4f91..1682d7b8eb 100644 --- a/compiler/ptype.pas +++ b/compiler/ptype.pas @@ -546,23 +546,30 @@ implementation lv,hv : TConstExprInt; old_block_type : tblock_type; dospecialize : boolean; + objdef: TDef; begin old_block_type:=block_type; dospecialize:=false; { use of current parsed object: - classes can be used also in classes - objects can be parameters } - if (token=_ID) and - assigned(current_objectdef) and - (current_objectdef.objname^=pattern) and - ( - (testcurobject=2) or - is_class_or_interface_or_objc(current_objectdef) - )then + if (token=_ID) then begin - consume(_ID); - def:=current_objectdef; - exit; + objdef:=current_objectdef; + while Assigned(objdef) and (objdef.typ=objectdef) do + begin + if (tobjectdef(objdef).objname^=pattern) and + ( + (testcurobject=2) or + is_class_or_interface_or_objc(objdef) + ) then + begin + consume(_ID); + def:=objdef; + exit; + end; + objdef:=tobjectdef(tobjectdef(objdef).owner.defowner); + end; end; { Generate a specialization? } if try_to_consume(_SPECIALIZE) then diff --git a/tests/webtbs/tw17945.pp b/tests/webtbs/tw17945.pp new file mode 100644 index 0000000000..c8b262a11d --- /dev/null +++ b/tests/webtbs/tw17945.pp @@ -0,0 +1,14 @@ +program tw17945; +{$mode delphi} +type + TFoo = class + public + type + TEnumerator = object + private + FFoo: TFoo; //Was error: Illegal expression + end; + end; + +begin +end. \ No newline at end of file