Sfoglia il codice sorgente

* fix for Mantis #23071: also store local symtable in the PPU if the procdef is generic as we need it to resolve genericdefs to nested types

git-svn-id: trunk@42459 -
svenbarth 6 anni fa
parent
commit
43b5dbf613
4 ha cambiato i file con 57 aggiunte e 16 eliminazioni
  1. 2 0
      .gitattributes
  2. 25 16
      compiler/symdef.pas
  3. 10 0
      tests/webtbs/tw23071.pp
  4. 20 0
      tests/webtbs/uw23071.pp

+ 2 - 0
.gitattributes

@@ -15980,6 +15980,7 @@ tests/webtbs/tw2300.pp svneol=native#text/plain
 tests/webtbs/tw2305.pp svneol=native#text/plain
 tests/webtbs/tw2305.pp svneol=native#text/plain
 tests/webtbs/tw2306.pp svneol=native#text/plain
 tests/webtbs/tw2306.pp svneol=native#text/plain
 tests/webtbs/tw2307.pp svneol=native#text/plain
 tests/webtbs/tw2307.pp svneol=native#text/plain
+tests/webtbs/tw23071.pp svneol=native#text/pascal
 tests/webtbs/tw23109.pp svneol=native#text/plain
 tests/webtbs/tw23109.pp svneol=native#text/plain
 tests/webtbs/tw2311.pp svneol=native#text/plain
 tests/webtbs/tw2311.pp svneol=native#text/plain
 tests/webtbs/tw23130.pp svneol=native#text/pascal
 tests/webtbs/tw23130.pp svneol=native#text/pascal
@@ -17224,6 +17225,7 @@ tests/webtbs/uw2266b.pas svneol=native#text/plain
 tests/webtbs/uw2269.inc svneol=native#text/plain
 tests/webtbs/uw2269.inc svneol=native#text/plain
 tests/webtbs/uw22741a.pp svneol=native#text/plain
 tests/webtbs/uw22741a.pp svneol=native#text/plain
 tests/webtbs/uw22741b.pp svneol=native#text/plain
 tests/webtbs/uw22741b.pp svneol=native#text/plain
+tests/webtbs/uw23071.pp svneol=native#text/pascal
 tests/webtbs/uw23204.pp svneol=native#text/plain
 tests/webtbs/uw23204.pp svneol=native#text/plain
 tests/webtbs/uw2364.pp svneol=native#text/plain
 tests/webtbs/uw2364.pp svneol=native#text/plain
 tests/webtbs/uw25054a.pp svneol=native#text/pascal
 tests/webtbs/uw25054a.pp svneol=native#text/pascal

+ 25 - 16
compiler/symdef.pas

@@ -773,6 +773,8 @@ interface
            procdef has been handled }
            procdef has been handled }
          implprocdefinfo : pimplprocdefinfo;
          implprocdefinfo : pimplprocdefinfo;
 
 
+         function store_localst:boolean;
+
          function GetResultName: PShortString;
          function GetResultName: PShortString;
          procedure SetResultName(AValue: PShortString);
          procedure SetResultName(AValue: PShortString);
          function GetParentFPStruct: tsym;
          function GetParentFPStruct: tsym;
@@ -5716,6 +5718,13 @@ implementation
                                   TPROCDEF
                                   TPROCDEF
 ***************************************************************************}
 ***************************************************************************}
 
 
+
+    function tprocdef.store_localst: boolean;
+      begin
+        result:=has_inlininginfo or (df_generic in defoptions);
+      end;
+
+
     function tprocdef.GetResultName: PShortString;
     function tprocdef.GetResultName: PShortString;
       begin
       begin
         if not assigned(implprocdefinfo) then
         if not assigned(implprocdefinfo) then
@@ -6039,7 +6048,7 @@ implementation
          parast:=tparasymtable.create(self,level);
          parast:=tparasymtable.create(self,level);
          tparasymtable(parast).ppuload(ppufile);
          tparasymtable(parast).ppuload(ppufile);
          { load local symtable }
          { load local symtable }
-         if has_inlininginfo then
+         if store_localst then
           begin
           begin
             localst:=tlocalsymtable.create(self,level);
             localst:=tlocalsymtable.create(self,level);
             tlocalsymtable(localst).ppuload(ppufile);
             tlocalsymtable(localst).ppuload(ppufile);
@@ -6221,7 +6230,7 @@ implementation
 
 
          { save localsymtable for inline procedures or when local
          { save localsymtable for inline procedures or when local
            browser info is requested, this has no influence on the crc }
            browser info is requested, this has no influence on the crc }
-         if has_inlininginfo then
+         if store_localst and not ppufile.crc_only then
           begin
           begin
             oldintfcrc:=ppufile.do_crc;
             oldintfcrc:=ppufile.do_crc;
             ppufile.do_crc:=false;
             ppufile.do_crc:=false;
@@ -6512,16 +6521,16 @@ implementation
       begin
       begin
          inherited buildderefimpl;
          inherited buildderefimpl;
 
 
+         { Localst is not available for main/unit init }
+         if store_localst and assigned(localst) then
+           begin
+             tlocalsymtable(localst).buildderef;
+             tlocalsymtable(localst).buildderefimpl;
+           end;
+
          { inline tree }
          { inline tree }
          if has_inlininginfo then
          if has_inlininginfo then
            begin
            begin
-             { Localst is not available for main/unit init }
-             if assigned(localst) then
-               begin
-                 tlocalsymtable(localst).buildderef;
-                 tlocalsymtable(localst).buildderefimpl;
-               end;
-
              funcretsymderef.build(funcretsym);
              funcretsymderef.build(funcretsym);
              inlininginfo^.code.buildderefimpl;
              inlininginfo^.code.buildderefimpl;
            end;
            end;
@@ -6546,16 +6555,16 @@ implementation
          if assigned(inlininginfo) then
          if assigned(inlininginfo) then
            has_inlininginfo:=true;
            has_inlininginfo:=true;
 
 
+         { Locals }
+         if store_localst and assigned(localst) then
+           begin
+             tlocalsymtable(localst).deref(false);
+             tlocalsymtable(localst).derefimpl(false);
+           end;
+
         { Inline }
         { Inline }
         if has_inlininginfo then
         if has_inlininginfo then
           begin
           begin
-            { Locals }
-            if assigned(localst) then
-              begin
-                tlocalsymtable(localst).deref(false);
-                tlocalsymtable(localst).derefimpl(false);
-              end;
-
             inlininginfo^.code.derefimpl;
             inlininginfo^.code.derefimpl;
             { funcretsym, this is always located in the localst }
             { funcretsym, this is always located in the localst }
             funcretsym:=tsym(funcretsymderef.resolve);
             funcretsym:=tsym(funcretsymderef.resolve);

+ 10 - 0
tests/webtbs/tw23071.pp

@@ -0,0 +1,10 @@
+{ %NORUN }
+{ %RECOMPILE }
+
+{$MODE DELPHI}
+
+uses uw23071;
+
+begin
+  TWrapper<Byte>.Z;
+end.

+ 20 - 0
tests/webtbs/uw23071.pp

@@ -0,0 +1,20 @@
+unit uw23071;
+
+{$MODE DELPHI}
+
+interface
+
+type
+  TWrapper<T> = record
+    class procedure Z; static;
+  end;
+
+implementation
+
+class procedure TWrapper<T>.Z;
+type
+  TLocalInteger = Integer;
+begin
+end;
+
+end.