Browse Source

* properly unlink unused type symbols from their defs to avoid
internal errors when generating debug info, resolves #40886

florian 10 months ago
parent
commit
44d9234f38
3 changed files with 25 additions and 0 deletions
  1. 11 0
      compiler/pgenutil.pas
  2. 1 0
      compiler/symtype.pas
  3. 13 0
      tests/webtbs/tw40886.pp

+ 11 - 0
compiler/pgenutil.pas

@@ -1342,6 +1342,17 @@ uses
                   end;
                   end;
               end;
               end;
           end;
           end;
+
+        { unlink unused defs }
+        if not(result) and assigned(callerparams) then
+          begin
+            for k:=0 to callerparams.count-1 do
+              begin
+                if tsym(callerparams[k]).typ=typesym then
+                  ttypesym(callerparams[k]).typedef.typesym:=nil;
+              end;
+          end;
+
         callerparams.free;
         callerparams.free;
       end;
       end;
 
 

+ 1 - 0
compiler/symtype.pas

@@ -415,6 +415,7 @@ implementation
           result:=result+GetTypeName;
           result:=result+GetTypeName;
       end;
       end;
 
 
+
     function tdef.fulltypename:string;
     function tdef.fulltypename:string;
       begin
       begin
         result:=fullownerhierarchyname(false);
         result:=fullownerhierarchyname(false);

+ 13 - 0
tests/webtbs/tw40886.pp

@@ -0,0 +1,13 @@
+{ %opt=-gl }
+program test;
+{$modeswitch implicitfunctionspecialization}
+
+generic procedure FillChar<T>(var x; count: SizeInt; value: Byte);
+begin
+end;
+
+var v: array [0..0] of Byte;
+
+begin
+  FillChar(v, 0, 0);
+end.