From 862f9dacea600791c3089f39d7de028c7310a468 Mon Sep 17 00:00:00 2001 From: florian Date: Sat, 31 Dec 2011 14:14:21 +0000 Subject: [PATCH] * handle int_to_bool for qwordbools correctly on arm git-svn-id: trunk@19933 - --- compiler/arm/narmcnv.pas | 24 +++++++++++++++++++++--- tests/webtbs/tw20889.pp | 14 +++++++++----- 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/compiler/arm/narmcnv.pas b/compiler/arm/narmcnv.pas index 559a008421..9dcfe1b48f 100644 --- a/compiler/arm/narmcnv.pas +++ b/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; diff --git a/tests/webtbs/tw20889.pp b/tests/webtbs/tw20889.pp index 9a7f420f1e..13fbe0f912 100644 --- a/tests/webtbs/tw20889.pp +++ b/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.