Browse Source

* corrected the def of the temp for array constructor nodes in case of
an array of const

git-svn-id: trunk@31777 -

Jonas Maebe 10 years ago
parent
commit
3b2bd718d8
1 changed files with 7 additions and 2 deletions
  1. 7 2
      compiler/ncgld.pas

+ 7 - 2
compiler/ncgld.pas

@@ -1117,6 +1117,7 @@ implementation
         hp    : tarrayconstructornode;
         hp    : tarrayconstructornode;
         href  : treference;
         href  : treference;
         lt    : tdef;
         lt    : tdef;
+        realresult: tdef;
         paraloc : tcgparalocation;
         paraloc : tcgparalocation;
         vtype : longint;
         vtype : longint;
         eledef: tdef;
         eledef: tdef;
@@ -1135,11 +1136,15 @@ implementation
           begin
           begin
             eledef:=search_system_type('TVARREC').typedef;
             eledef:=search_system_type('TVARREC').typedef;
             elesize:=eledef.size;
             elesize:=eledef.size;
+            { in this case, the elementdef is set to "void", so create an
+              array of tvarrec instead }
+            realresult:=carraydef.getreusable(eledef,tarraydef(resultdef).highrange+1);
           end
           end
         else
         else
           begin
           begin
             eledef:=tarraydef(resultdef).elementdef;
             eledef:=tarraydef(resultdef).elementdef;
             elesize:=tarraydef(resultdef).elesize;
             elesize:=tarraydef(resultdef).elesize;
+            realresult:=resultdef;
           end;
           end;
         { alignment is filled in by tg.gethltemp below }
         { alignment is filled in by tg.gethltemp below }
         location_reset_ref(location,LOC_CREFERENCE,OS_NO,0);
         location_reset_ref(location,LOC_CREFERENCE,OS_NO,0);
@@ -1152,9 +1157,9 @@ implementation
           allocating a temp of size 0 also forces it to be size 4 on regular
           allocating a temp of size 0 also forces it to be size 4 on regular
           targets }
           targets }
          if tarraydef(resultdef).highrange=-1 then
          if tarraydef(resultdef).highrange=-1 then
-           tg.gethltemp(current_asmdata.CurrAsmList,resultdef,0,tt_normal,location.reference)
+           tg.gethltemp(current_asmdata.CurrAsmList,realresult,0,tt_normal,location.reference)
          else
          else
-           tg.gethltemp(current_asmdata.CurrAsmList,resultdef,(tarraydef(resultdef).highrange+1)*elesize,tt_normal,location.reference);
+           tg.gethltemp(current_asmdata.CurrAsmList,realresult,(tarraydef(resultdef).highrange+1)*elesize,tt_normal,location.reference);
          href:=location.reference;
          href:=location.reference;
          makearrayref(href,eledef);
          makearrayref(href,eledef);
         { Process nodes in array constructor }
         { Process nodes in array constructor }