ソースを参照

* I hope it's proper fix for r10688.

git-svn-id: trunk@10690 -
yury 17 年 前
コミット
b70bf05ad5

+ 3 - 2
compiler/arm/narmcnv.pas

@@ -198,8 +198,9 @@ implementation
            begin
               location_copy(location,left.location);
               newsize:=def_cgsize(resultdef);
-              { change of size/sign? Then we have to sign/zero-extend }
-              if (newsize<>left.location.size) then
+              { change of size? change sign only if location is LOC_(C)REGISTER? Then we have to sign/zero-extend }
+              if (tcgsize2size[newsize]<>tcgsize2size[left.location.size]) or
+                 ((newsize<>left.location.size) and (location.loc in [LOC_REGISTER,LOC_CREGISTER])) then
                 location_force_reg(current_asmdata.CurrAsmList,location,newsize,true)
               else
                 location.size:=newsize;

+ 3 - 2
compiler/m68k/n68kcnv.pas

@@ -172,8 +172,9 @@ implementation
            begin
               location_copy(location,left.location);
               newsize:=def_cgsize(resultdef);
-              { change of size/sign? Then we have to sign/zero-extend }
-              if (newsize<>left.location.size) then
+              { change of size? change sign only if location is LOC_(C)REGISTER? Then we have to sign/zero-extend }
+              if (tcgsize2size[newsize]<>tcgsize2size[left.location.size]) or
+                 ((newsize<>left.location.size) and (location.loc in [LOC_REGISTER,LOC_CREGISTER])) then
                 location_force_reg(current_asmdata.CurrAsmList,location,newsize,true)
               else
                 location.size:=newsize;

+ 10 - 0
compiler/ncnv.pas

@@ -2516,6 +2516,16 @@ implementation
             (left.resultdef.size=resultdef.size) and
             (left.expectloc in [LOC_REFERENCE,LOC_CREFERENCE,LOC_CREGISTER]) then
            exit;
+         { when converting 64bit int to C-ctyle boolean, first convert to a 32bit int and then   }
+         { convert to a boolean (only necessary for 32bit processors) }
+         if (left.resultdef.size > sizeof(aint)) and (left.resultdef.size<>resultdef.size)
+            and is_cbool(resultdef) then
+           begin
+             result := ctypeconvnode.create_internal(left,s32inttype);
+             left := nil;
+             firstpass(result);
+             exit;
+           end;
          expectloc:=LOC_REGISTER;
       end;
 

+ 3 - 2
compiler/ppcgen/ngppccnv.pas

@@ -93,8 +93,9 @@ implementation
            begin
               location_copy(location,left.location);
               newsize:=def_cgsize(resultdef);
-              { change of size/sign? Then we have to sign/zero-extend }
-              if (newsize<>left.location.size) then
+              { change of size? change sign only if location is LOC_(C)REGISTER? Then we have to sign/zero-extend }
+              if (tcgsize2size[newsize]<>tcgsize2size[left.location.size]) or
+                 ((newsize<>left.location.size) and (location.loc in [LOC_REGISTER,LOC_CREGISTER])) then
                 location_force_reg(current_asmdata.CurrAsmList,location,newsize,true)
               else
                 location.size:=newsize;

+ 3 - 2
compiler/sparc/ncpucnv.pas

@@ -241,8 +241,9 @@ implementation
            begin
               location_copy(location,left.location);
               newsize:=def_cgsize(resultdef);
-              { change of size/sign? Then we have to sign/zero-extend }
-              if (newsize<>left.location.size) then
+              { change of size? change sign only if location is LOC_(C)REGISTER? Then we have to sign/zero-extend }
+              if (tcgsize2size[newsize]<>tcgsize2size[left.location.size]) or
+                 ((newsize<>left.location.size) and (location.loc in [LOC_REGISTER,LOC_CREGISTER])) then
                 location_force_reg(current_asmdata.CurrAsmList,location,newsize,true)
               else
                 location.size:=newsize;

+ 3 - 2
compiler/x86/nx86cnv.pas

@@ -110,8 +110,9 @@ implementation
            begin
               location_copy(location,left.location);
               newsize:=def_cgsize(resultdef);
-              { change of size/sign? Then we have to sign/zero-extend }
-              if (newsize<>left.location.size) then
+              { change of size? change sign only if location is LOC_(C)REGISTER? Then we have to sign/zero-extend }
+              if (tcgsize2size[newsize]<>tcgsize2size[left.location.size]) or
+                 ((newsize<>left.location.size) and (location.loc in [LOC_REGISTER,LOC_CREGISTER])) then
                 location_force_reg(current_asmdata.CurrAsmList,location,newsize,true)
               else
                 location.size:=newsize;