Browse Source

+ symtable.pas, tspecializesymtable.create: SymList and DefList do not need to own the symbols and defs as they are moved to another symtable before the specialize symtable is destroyed (avoids the need to call "extract" on those lists)
* pgenutil.pas, generate_specialization: Correctly change the ownership of extracted symbols and defs by calling ChangeOwner on the symbol/def which does all the magic of changing the owner and adding it to the corresponding list of the given symtable. This fixes Mantis #21550
* Adjusted tw21550.pp so that it enforces the generation of debug information which (as this was the option which caused the above mentioned bug to show)

git-svn-id: trunk@21270 -

svenbarth 13 năm trước cách đây
mục cha
commit
810bd7ddab
3 tập tin đã thay đổi với 19 bổ sung6 xóa
  1. 6 6
      compiler/pgenutil.pas
  2. 11 0
      compiler/symtable.pas
  3. 2 0
      tests/webtbs/tw21550.pp

+ 6 - 6
compiler/pgenutil.pas

@@ -494,17 +494,17 @@ uses
             for i:=tempst.SymList.Count-1 downto 0 do
               begin
                 item:=tempst.SymList.Items[i];
-                specializest.SymList.Add(tempst.SymList.NameOfIndex(i),item);
-                tsym(item).Owner:=specializest;
-                tempst.SymList.Extract(item);
+                { using changeowner the symbol is automatically added to the
+                  new symtable }
+                tsym(item).ChangeOwner(specializest);
               end;
 
             for i:=tempst.DefList.Count-1 downto 0 do
               begin
                 item:=tempst.DefList.Items[i];
-                specializest.DefList.Add(item);
-                tdef(item).owner:=specializest;
-                tempst.DefList.Extract(item);
+                { using changeowner the def is automatically added to the new
+                  symtable }
+                tdef(item).ChangeOwner(specializest);
               end;
 
             tempst.free;

+ 11 - 0
compiler/symtable.pas

@@ -168,6 +168,7 @@ interface
 
        tspecializesymtable = class(tglobalsymtable)
        public
+          constructor create(const n : string;id:word);
           function iscurrentunit:boolean;override;
        end;
 
@@ -1626,6 +1627,16 @@ implementation
                              tspecializesymtable
 *****************************************************************************}
 
+    constructor tspecializesymtable.create(const n : string;id:word);
+      begin
+        inherited create(n,id);
+        { the specialize symtable does not own the syms and defs as they are all
+          moved to a different symtable before the symtable is destroyed; this
+          avoids calls to "extract" }
+        symlist.ownsobjects:=false;
+        deflist.ownsobjects:=false;
+      end;
+
     function tspecializesymtable.iscurrentunit: boolean;
       begin
         Result := true;

+ 2 - 0
tests/webtbs/tw21550.pp

@@ -1,3 +1,5 @@
+{%OPT=-gl}
+
 program tw21550;
 
 {$mode objfpc}