mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2026-02-19 19:36:26 +01:00
* better fix and test for #41488
This commit is contained in:
parent
7b790ec5a8
commit
58d2420c1e
@ -4490,14 +4490,9 @@ implementation
|
||||
{$endif}
|
||||
begin
|
||||
{ create constant 1, ensure the data type is large enough }
|
||||
if (left.resultdef is tenumdef) then
|
||||
range_to_type(
|
||||
min(1,tenumdef(left.resultdef).min),
|
||||
max(1,tenumdef(left.resultdef).max),hdef)
|
||||
else
|
||||
range_to_type(
|
||||
min(1,torddef(left.resultdef).low),
|
||||
max(1,torddef(left.resultdef).high),hdef);
|
||||
range_to_type(
|
||||
min(1,get_min_value(left.resultdef)),
|
||||
max(1,get_max_value(left.resultdef)),hdef);
|
||||
hp:=cordconstnode.create(1,hdef,false);
|
||||
typecheckpass(hp);
|
||||
if not is_integer(hp.resultdef) then
|
||||
@ -5070,14 +5065,9 @@ implementation
|
||||
else
|
||||
begin
|
||||
{ no, create constant 1, ensure the data type is large enough }
|
||||
if (left.resultdef is tenumdef) then
|
||||
range_to_type(
|
||||
min(1,tenumdef(tcallparanode(left).left.resultdef).min),
|
||||
max(1,tenumdef(tcallparanode(left).left.resultdef).max),hdef)
|
||||
else
|
||||
range_to_type(
|
||||
min(1,torddef(tcallparanode(left).left.resultdef).low),
|
||||
max(1,torddef(tcallparanode(left).left.resultdef).high),hdef);
|
||||
range_to_type(
|
||||
min(1,get_min_value(tcallparanode(left).left.resultdef)),
|
||||
max(1,get_max_value(tcallparanode(left).left.resultdef)),hdef);
|
||||
hpp:=cordconstnode.create(1,hdef,false)
|
||||
end;
|
||||
typecheckpass(hpp);
|
||||
|
||||
@ -4,10 +4,15 @@ type
|
||||
TTest = 10..20;
|
||||
var
|
||||
A: TTest;
|
||||
S: String;
|
||||
begin
|
||||
A := 10;
|
||||
Inc(A);
|
||||
Writeln(Succ(A)); // 12
|
||||
Writeln(Pred(A)); // 10
|
||||
Str(Succ(A), S); // 12
|
||||
if S <> '12' then
|
||||
halt(1);
|
||||
Str(Pred(A), S); // 10
|
||||
if S <> '10' then
|
||||
halt(2);
|
||||
Dec(A);
|
||||
end.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user