From 1afab1ab6926c0854245e6113787c81bd9e88f10 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Tue, 29 Nov 2016 21:54:33 +0000 Subject: [PATCH] * moved the floating point constant range checking code from pass_generate_code to pass_typecheck, so that it's also used by targets that override pass_generate_code (fixes webtbs/tw16315b for LLVM) git-svn-id: trunk@35021 - --- compiler/ncgcon.pas | 19 ------------------- compiler/ncon.pas | 46 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/compiler/ncgcon.pas b/compiler/ncgcon.pas index 6d67c746d9..ad48f1f445 100644 --- a/compiler/ncgcon.pas +++ b/compiler/ncgcon.pas @@ -144,10 +144,6 @@ implementation aitrealconst_s32bit : begin current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s32real(ts32real(value_real))); - { range checking? } - if floating_point_range_check_error and - (tai_realconst(current_asmdata.asmlists[al_typedconsts].last).value.s32val=MathInf.Value) then - Message(parser_e_range_check_error); end; aitrealconst_s64bit : @@ -158,31 +154,16 @@ implementation else {$endif ARM} current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s64real(ts64real(value_real))); - - { range checking? } - if floating_point_range_check_error and - (tai_realconst(current_asmdata.asmlists[al_typedconsts].last).value.s64val=MathInf.Value) then - Message(parser_e_range_check_error); end; aitrealconst_s80bit : begin current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s80real(value_real,tfloatdef(resultdef).size)); - - { range checking? } - if floating_point_range_check_error and - (tai_realconst(current_asmdata.asmlists[al_typedconsts].last).value.s80val=MathInf.Value) then - Message(parser_e_range_check_error); end; {$ifdef cpufloat128} aitrealconst_s128bit : begin current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s128real(value_real)); - - { range checking? } - if floating_point_range_check_error and - (tai_realconst(current_asmdata.asmlists[al_typedconsts].last).value.s128val=MathInf.Value) then - Message(parser_e_range_check_error); end; {$endif cpufloat128} diff --git a/compiler/ncon.pas b/compiler/ncon.pas index 6329a4056a..f8ee8bf8b1 100644 --- a/compiler/ncon.pas +++ b/compiler/ncon.pas @@ -391,12 +391,57 @@ implementation dogetcopy:=n; end; + function trealconstnode.pass_typecheck:tnode; begin result:=nil; resultdef:=typedef; + + { range checking? } + if floating_point_range_check_error or + (tfloatdef(resultdef).floattype in [s64comp,s64currency]) then + begin + { use CGMessage so that the resultdef will get set to errordef + by pass1.typecheckpass_internal if a range error was triggered, + which in turn will prevent any potential parent type conversion + node from creating a new realconstnode with this exact same value + and hence trigger the same error again } + case tfloatdef(resultdef).floattype of + s32real : + begin + if ts32real(value_real)=MathInf.Value then + CGMessage(parser_e_range_check_error); + end; + s64real: + begin + if ts64real(value_real)=MathInf.Value then + CGMessage(parser_e_range_check_error); + end; + s80real, + sc80real: + begin + if ts80real(value_real)=MathInf.Value then + CGMessage(parser_e_range_check_error); + end; + s64comp, + s64currency: + begin + if (value_real>9223372036854775807.0) or + (value_real<-9223372036854775808.0) then + CGMessage(parser_e_range_check_error) + end; + s128real: + begin + if ts128real(value_real)=MathInf.Value then + CGMessage(parser_e_range_check_error); + end; + else + internalerror(2016112902); + end; + end; end; + function trealconstnode.pass_1 : tnode; begin result:=nil; @@ -405,6 +450,7 @@ implementation include(current_procinfo.flags,pi_needs_got); end; + function trealconstnode.docompare(p: tnode): boolean; begin docompare :=