فهرست منبع

* don't emit default values for local variables in generic routines: those
default values are not used, and they are not type-correct (and hence
cause trouble with LLVM)

git-svn-id: trunk@33992 -

Jonas Maebe 9 سال پیش
والد
کامیت
899add8c7d
1فایلهای تغییر یافته به همراه13 افزوده شده و 2 حذف شده
  1. 13 2
      compiler/pdecvar.pas

+ 13 - 2
compiler/pdecvar.pas

@@ -1056,6 +1056,7 @@ implementation
         var
           vs : tabstractnormalvarsym;
           tcsym : tstaticvarsym;
+          templist : tasmlist;
         begin
           vs:=tabstractnormalvarsym(sc[0]);
           if sc.count>1 then
@@ -1068,9 +1069,19 @@ implementation
               begin
                 tcsym:=cstaticvarsym.create('$default'+vs.realname,vs_const,vs.vardef,[],true);
                 include(tcsym.symoptions,sp_internal);
-                vs.defaultconstsym:=tcsym;
                 symtablestack.top.insert(tcsym);
-                read_typed_const(current_asmdata.asmlists[al_typedconsts],tcsym,false);
+                templist:=tasmlist.create;
+                read_typed_const(templist,tcsym,false);
+                { in case of a generic routine, this initialisation value is not
+                  used, and will be re-parsed during specialisations (and the
+                  current version is not type-correct and hence breaks code
+                  generation for LLVM) }
+                if not parse_generic then
+                  begin
+                    vs.defaultconstsym:=tcsym;
+                    current_asmdata.asmlists[al_typedconsts].concatlist(templist);
+                  end;
+                templist.free;
               end;
             staticvarsym :
               begin