diff --git a/compiler/aarch64/ncpuinl.pas b/compiler/aarch64/ncpuinl.pas index 9bac0b8901..7a16130042 100644 --- a/compiler/aarch64/ncpuinl.pas +++ b/compiler/aarch64/ncpuinl.pas @@ -61,7 +61,7 @@ implementation uses globtype,verbose,globals, compinnr, - cpuinfo, defutil,symdef,aasmdata,aasmcpu, + cpuinfo, defutil,symdef,aasmbase,aasmdata,aasmcpu, cgbase,cgutils,pass_1,pass_2, procinfo, ncal,nutils, @@ -183,6 +183,7 @@ implementation procedure taarch64inlinenode.second_abs_long; var opsize : tcgsize; + hl: TAsmLabel; begin secondpass(left); opsize:=def_cgsize(left.resultdef); @@ -190,6 +191,15 @@ implementation location:=left.location; location.register:=cg.getintregister(current_asmdata.CurrAsmList,opsize); + if cs_check_overflow in current_settings.localswitches then + begin + current_asmdata.getjumplabel(hl); + hlcg.a_cmp_const_reg_label(current_asmdata.CurrAsmList,resultdef,OC_NE,torddef(resultdef).low.svalue,left.location.register,hl); + hlcg.a_reg_dealloc(current_asmdata.CurrAsmList, NR_DEFAULTFLAGS); + hlcg.g_call_system_proc(current_asmdata.CurrAsmList,'fpc_overflow',[],nil).resetiftemp; + hlcg.a_label(current_asmdata.CurrAsmList,hl); + end; + current_asmdata.CurrAsmList.concat(setoppostfix(taicpu.op_reg_reg(A_NEG,location.register,left.location.register),PF_S)); current_asmdata.CurrAsmList.concat(taicpu.op_reg_reg_reg_cond(A_CSEL,location.register,location.register,left.location.register,C_GE)); end; diff --git a/tests/test/units/system/tabs.pp b/tests/test/units/system/tabs.pp index 652080966b..383a2358a1 100644 --- a/tests/test/units/system/tabs.pp +++ b/tests/test/units/system/tabs.pp @@ -167,8 +167,6 @@ procedure fail; except on EIntOverflow do ; // no error, result is -2147483648 - on ERangeError do - ; // no error, result is -2147483648 on Exception do _result := false; end; @@ -256,8 +254,6 @@ procedure fail; { test overflow checking } {$PUSH} {$Q+} -{ allow also range check errors as 64 bit CPUs might have only an abs(<int64>) } -{$R+} value := Longint.MinValue+Random(0); try value := Abs(value); @@ -265,8 +261,6 @@ procedure fail; except on EIntOverflow do ; // no error, result is -2147483648 - on ERangeError do - ; // no error, result is -2147483648 on Exception do _result := false; end;