Browse Source

* handle int_to_bool for qwordbools correctly on arm

git-svn-id: trunk@19933 -
florian 13 years ago
parent
commit
862f9dacea
2 changed files with 30 additions and 8 deletions
  1. 21 3
      compiler/arm/narmcnv.pas
  2. 9 5
      tests/webtbs/tw20889.pp

+ 21 - 3
compiler/arm/narmcnv.pas

@@ -215,6 +215,7 @@ implementation
 
     procedure tarmtypeconvnode.second_int_to_bool;
       var
+        hreg1,
         hregister : tregister;
         href      : treference;
         resflags  : tresflags;
@@ -311,10 +312,27 @@ implementation
          end;
          { load flags to register }
          location_reset(location,LOC_REGISTER,def_cgsize(resultdef));
-         location.register:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
-         cg.g_flags2reg(current_asmdata.CurrAsmList,location.size,resflags,location.register);
+         hreg1:=cg.getintregister(current_asmdata.CurrAsmList,location.size);
+         cg.g_flags2reg(current_asmdata.CurrAsmList,location.size,resflags,hreg1);
          if (is_cbool(resultdef)) then
-           cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,location.size,location.register,location.register);
+           cg.a_op_reg_reg(current_asmdata.CurrAsmList,OP_NEG,location.size,hreg1,hreg1);
+
+{$ifndef cpu64bitalu}
+         if (location.size in [OS_64,OS_S64]) then
+           begin
+             location.register64.reglo:=hreg1;
+             location.register64.reghi:=cg.getintregister(current_asmdata.CurrAsmList,OS_32);
+             if (is_cbool(resultdef)) then
+               { reglo is either 0 or -1 -> reghi has to become the same }
+               cg.a_load_reg_reg(current_asmdata.CurrAsmList,OS_32,OS_32,location.register64.reglo,location.register64.reghi)
+             else
+               { unsigned }
+               cg.a_load_const_reg(current_asmdata.CurrAsmList,OS_32,0,location.register64.reghi);
+           end
+         else
+{$endif cpu64bitalu}
+           location.register:=hreg1;
+
          current_procinfo.CurrTrueLabel:=oldTrueLabel;
          current_procinfo.CurrFalseLabel:=oldFalseLabel;
       end;

+ 9 - 5
tests/webtbs/tw20889.pp

@@ -10,10 +10,14 @@ program qwordbool_test_02;
 // Sample:
 //
 function qbool_result(something:integer):qwordbool;
-begin qbool_result:=(something<>0);
-      end;
+  begin 
+    qbool_result:=(something<>0);
+  end;
 
 var   test:boolean;
-begin test:=qbool_result(123);  //here(17,13) Fatal: Internal error 200410105
-      writeln(test);
-      end.
+begin 
+  test:=qbool_result(123);  //here(17,13) Fatal: Internal error 200410105
+  if not(test) then
+    halt(1);
+  writeln('ok');      
+end.