浏览代码

* renamed the first parameter of is_owned_by() from "childdef" into
"nesteddef", because it's about def's owned by other defs, not about
parent/child relations like in OOP
* stop checking whether a def is owned by another one when we reach a
para/localsymtable, since a type declared locally in a record/object
method is not nested inside the record/object type (fixes mantis
#23819)

git-svn-id: trunk@23582 -

Jonas Maebe 12 年之前
父节点
当前提交
a972de5a32
共有 3 个文件被更改,包括 48 次插入5 次删除
  1. 1 0
      .gitattributes
  2. 9 5
      compiler/symtable.pas
  3. 38 0
      tests/webtbs/tw23819.pp

+ 1 - 0
.gitattributes

@@ -13184,6 +13184,7 @@ tests/webtbs/tw23725.pp svneol=native#text/pascal
 tests/webtbs/tw23744.pp svneol=native#text/plain
 tests/webtbs/tw2377.pp svneol=native#text/plain
 tests/webtbs/tw2378.pp svneol=native#text/plain
+tests/webtbs/tw23819.pp -text svneol=native#text/plain
 tests/webtbs/tw2382.pp svneol=native#text/plain
 tests/webtbs/tw2388.pp svneol=native#text/plain
 tests/webtbs/tw2397.pp svneol=native#text/plain

+ 9 - 5
compiler/symtable.pas

@@ -223,7 +223,7 @@ interface
 
 {*** Search ***}
     procedure addsymref(sym:tsym);
-    function  is_owned_by(childdef,ownerdef:tdef):boolean;
+    function  is_owned_by(nesteddef,ownerdef:tdef):boolean;
     function  sym_is_owned_by(childsym:tsym;symtable:tsymtable):boolean;
     function  defs_belong_to_same_generic(def1,def2:tdef):boolean;
     function  get_generic_in_hierarchy_by_name(srsym:tsym;def:tdef):tdef;
@@ -2070,11 +2070,15 @@ implementation
        end;
 
 
-    function is_owned_by(childdef,ownerdef:tdef):boolean;
+    function is_owned_by(nesteddef,ownerdef:tdef):boolean;
       begin
-        result:=childdef=ownerdef;
-        if not result and assigned(childdef.owner.defowner) then
-          result:=is_owned_by(tdef(childdef.owner.defowner),ownerdef);
+        result:=nesteddef=ownerdef;
+        if not result and
+           { types declared locally in a record method are not defined in the
+             record itself }
+           not(nesteddef.owner.symtabletype in [localsymtable,parasymtable]) and
+           assigned(nesteddef.owner.defowner) then
+          result:=is_owned_by(tdef(nesteddef.owner.defowner),ownerdef);
       end;
 
     function sym_is_owned_by(childsym:tsym;symtable:tsymtable):boolean;

+ 38 - 0
tests/webtbs/tw23819.pp

@@ -0,0 +1,38 @@
+{ %norun }
+
+program tw23819;
+
+  type
+    fixstring = string [ 255 ] ;
+    t9496 = ( t94, t96 ) ;
+    tSD = ( sdSingle94, sdSingle96, sdDOuble94, sdDouble96 ) ;
+    tg = ( G0, G1, G2, G3 ) ;
+    tG13 = G1..G3 ;
+    tl = #$40..#$7f ;
+    ESCstring = string [ 7 ] ;
+    tgl9496 = {packed} object
+                sd : tSD ;
+                g : tg ;
+                l : tl ;
+                n : t9496 ;
+                procedure Put ( const pESCseq : ESCstring ) ;
+               end ;
+
+  procedure tgl9496.Put ( const pESCseq : ESCstring ) ;
+
+    var
+      yp : tgl9496 ;
+      locals : record
+                 Lst : FixString ;
+                 gc : Char ;
+                 gp,
+                 letp : LongInt ;
+                 xp : tgl9496 ;
+                end ;
+
+    begin
+    end ;
+
+
+begin
+end.