mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-20 19:29:26 +02:00
* additional fix for r48449
git-svn-id: trunk@48461 -
This commit is contained in:
parent
91050f14b6
commit
8496690ed0
@ -938,6 +938,7 @@ implementation
|
||||
htype,elementdef,elementptrdef : tdef;
|
||||
newordtyp: tordtype;
|
||||
valid : boolean;
|
||||
minvalue, maxvalue: Tconstexprint;
|
||||
begin
|
||||
result:=nil;
|
||||
typecheckpass(left);
|
||||
@ -1054,10 +1055,19 @@ implementation
|
||||
begin
|
||||
{ in case of an integer type, we need a new type which covers declaration range and index range,
|
||||
see tests/webtbs/tw38413.pp
|
||||
|
||||
This matters only if we sign extend, if the type exceeds the sint range, we can fall back only
|
||||
to the index type
|
||||
}
|
||||
if is_integer(right.resultdef) then
|
||||
newordtyp:=range_to_basetype(min(TConstExprInt(Tarraydef(left.resultdef).lowrange),torddef(right.resultdef).low),
|
||||
max(TConstExprInt(Tarraydef(left.resultdef).highrange),torddef(right.resultdef).high))
|
||||
if is_integer(right.resultdef) and ((torddef(right.resultdef).low<0) or (TConstExprInt(Tarraydef(left.resultdef).lowrange)<0)) then
|
||||
begin
|
||||
minvalue:=min(TConstExprInt(Tarraydef(left.resultdef).lowrange),torddef(right.resultdef).low);
|
||||
maxvalue:=max(TConstExprInt(Tarraydef(left.resultdef).highrange),torddef(right.resultdef).high);
|
||||
if maxvalue>torddef(sinttype).high then
|
||||
newordtyp:=Torddef(right.resultdef).ordtype
|
||||
else
|
||||
newordtyp:=range_to_basetype(minvalue,maxvalue);
|
||||
end
|
||||
else
|
||||
newordtyp:=Torddef(right.resultdef).ordtype;
|
||||
end
|
||||
@ -1068,6 +1078,7 @@ implementation
|
||||
int64(Tarraydef(left.resultdef).highrange),
|
||||
true
|
||||
));
|
||||
printnode(self);
|
||||
end
|
||||
else
|
||||
begin
|
||||
|
Loading…
Reference in New Issue
Block a user