mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-13 09:59:08 +02:00
* only enumerations have range checking for succ/pred in const section
This commit is contained in:
parent
c5eb27f475
commit
98468d63e9
@ -1115,6 +1115,7 @@ implementation
|
|||||||
hp : tnode;
|
hp : tnode;
|
||||||
srsym : tsym;
|
srsym : tsym;
|
||||||
isreal : boolean;
|
isreal : boolean;
|
||||||
|
checkrange : boolean;
|
||||||
label
|
label
|
||||||
myexit;
|
myexit;
|
||||||
begin
|
begin
|
||||||
@ -1595,14 +1596,20 @@ implementation
|
|||||||
(tenumdef(resulttype.def).has_jumps) then
|
(tenumdef(resulttype.def).has_jumps) then
|
||||||
CGMessage(type_e_succ_and_pred_enums_with_assign_not_possible);
|
CGMessage(type_e_succ_and_pred_enums_with_assign_not_possible);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ only if the result is an enum do we do range checking }
|
||||||
|
if (resulttype.def.deftype=enumdef) then
|
||||||
|
checkrange := true
|
||||||
|
else
|
||||||
|
checkrange := false;
|
||||||
|
|
||||||
{ do constant folding after check for jumps }
|
{ do constant folding after check for jumps }
|
||||||
if left.nodetype=ordconstn then
|
if left.nodetype=ordconstn then
|
||||||
begin
|
begin
|
||||||
if inlinenumber=in_succ_x then
|
if inlinenumber=in_succ_x then
|
||||||
hp:=cordconstnode.create(tordconstnode(left).value+1,left.resulttype,true)
|
hp:=cordconstnode.create(tordconstnode(left).value+1,left.resulttype,checkrange)
|
||||||
else
|
else
|
||||||
hp:=cordconstnode.create(tordconstnode(left).value-1,left.resulttype,true);
|
hp:=cordconstnode.create(tordconstnode(left).value-1,left.resulttype,checkrange);
|
||||||
result:=hp;
|
result:=hp;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -2380,7 +2387,10 @@ begin
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.89 2002-09-09 19:41:01 peter
|
Revision 1.90 2002-09-13 19:12:09 carl
|
||||||
|
* only enumerations have range checking for succ/pred in const section
|
||||||
|
|
||||||
|
Revision 1.89 2002/09/09 19:41:01 peter
|
||||||
* check ranges for pred() and succ()
|
* check ranges for pred() and succ()
|
||||||
|
|
||||||
Revision 1.88 2002/09/08 13:01:25 jonas
|
Revision 1.88 2002/09/08 13:01:25 jonas
|
||||||
|
Loading…
Reference in New Issue
Block a user