mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-08 02:45:56 +02:00
* 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 -
This commit is contained in:
parent
006c7e1ccf
commit
1afab1ab69
@ -144,10 +144,6 @@ implementation
|
|||||||
aitrealconst_s32bit :
|
aitrealconst_s32bit :
|
||||||
begin
|
begin
|
||||||
current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s32real(ts32real(value_real)));
|
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;
|
end;
|
||||||
|
|
||||||
aitrealconst_s64bit :
|
aitrealconst_s64bit :
|
||||||
@ -158,31 +154,16 @@ implementation
|
|||||||
else
|
else
|
||||||
{$endif ARM}
|
{$endif ARM}
|
||||||
current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s64real(ts64real(value_real)));
|
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;
|
end;
|
||||||
|
|
||||||
aitrealconst_s80bit :
|
aitrealconst_s80bit :
|
||||||
begin
|
begin
|
||||||
current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s80real(value_real,tfloatdef(resultdef).size));
|
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;
|
end;
|
||||||
{$ifdef cpufloat128}
|
{$ifdef cpufloat128}
|
||||||
aitrealconst_s128bit :
|
aitrealconst_s128bit :
|
||||||
begin
|
begin
|
||||||
current_asmdata.asmlists[al_typedconsts].concat(tai_realconst.create_s128real(value_real));
|
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;
|
end;
|
||||||
{$endif cpufloat128}
|
{$endif cpufloat128}
|
||||||
|
|
||||||
|
@ -391,12 +391,57 @@ implementation
|
|||||||
dogetcopy:=n;
|
dogetcopy:=n;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function trealconstnode.pass_typecheck:tnode;
|
function trealconstnode.pass_typecheck:tnode;
|
||||||
begin
|
begin
|
||||||
result:=nil;
|
result:=nil;
|
||||||
resultdef:=typedef;
|
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;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function trealconstnode.pass_1 : tnode;
|
function trealconstnode.pass_1 : tnode;
|
||||||
begin
|
begin
|
||||||
result:=nil;
|
result:=nil;
|
||||||
@ -405,6 +450,7 @@ implementation
|
|||||||
include(current_procinfo.flags,pi_needs_got);
|
include(current_procinfo.flags,pi_needs_got);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
function trealconstnode.docompare(p: tnode): boolean;
|
function trealconstnode.docompare(p: tnode): boolean;
|
||||||
begin
|
begin
|
||||||
docompare :=
|
docompare :=
|
||||||
|
Loading…
Reference in New Issue
Block a user