瀏覽代碼

* fixed widestring range checking on win64 (mantis #10450, fix also
depends on r10505)

git-svn-id: trunk@10506 -

Jonas Maebe 17 年之前
父節點
當前提交
242b335531
共有 1 個文件被更改,包括 27 次插入4 次删除
  1. 27 4
      compiler/ncgmem.pas

+ 27 - 4
compiler/ncgmem.pas

@@ -756,9 +756,19 @@ implementation
                               paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc2);
                               cg.a_param_const(current_asmdata.CurrAsmList,OS_INT,tordconstnode(right).value.svalue,paraloc2);
                               href:=location.reference;
-                              dec(href.offset,sizeof(pint)-offsetdec);
                               paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc1);
-                              cg.a_param_ref(current_asmdata.CurrAsmList,OS_INT,href,paraloc1);
+                              if not(tf_winlikewidestring in target_info.flags) or
+                                 (tstringdef(left.resultdef).stringtype<>st_widestring) then
+                                begin
+                                  dec(href.offset,sizeof(pint)-offsetdec);
+                                  cg.a_param_ref(current_asmdata.CurrAsmList,OS_ADDR,href,paraloc1);
+                                end
+                              else
+                                begin
+                                  { winlike widestrings have a 4 byte length }
+                                  dec(href.offset,4-offsetdec);
+                                  cg.a_param_ref(current_asmdata.CurrAsmList,OS_32,href,paraloc1);
+                                end;
                               paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc1);
                               paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc2);
                               cg.allocallcpuregisters(current_asmdata.CurrAsmList);
@@ -910,9 +920,22 @@ implementation
                               cg.a_param_reg(current_asmdata.CurrAsmList,OS_INT,right.location.register,paraloc2);
                               href:=location.reference;
                               dec(href.offset,sizeof(pint)-offsetdec);
-                              //dec(href.offset,7);
+
+                              href:=location.reference;
                               paramanager.allocparaloc(current_asmdata.CurrAsmList,paraloc1);
-                              cg.a_param_ref(current_asmdata.CurrAsmList,OS_INT,href,paraloc1);
+                              if not(tf_winlikewidestring in target_info.flags) or
+                                 (tstringdef(left.resultdef).stringtype<>st_widestring) then
+                                begin
+                                  dec(href.offset,sizeof(pint)-offsetdec);
+                                  cg.a_param_ref(current_asmdata.CurrAsmList,OS_ADDR,href,paraloc1);
+                                end
+                              else
+                                begin
+                                  { winlike widestrings have a 4 byte length }
+                                  dec(href.offset,4-offsetdec);
+                                  cg.a_param_ref(current_asmdata.CurrAsmList,OS_32,href,paraloc1);
+                                end;
+
                               paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc1);
                               paramanager.freeparaloc(current_asmdata.CurrAsmList,paraloc2);
                               cg.allocallcpuregisters(current_asmdata.CurrAsmList);