mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-08 11:19:36 +02:00
* sizeof(array) and length(array) must return sizeUint in case the array
size does not fit in sizeint. This fixes a range check error during compilation on small CPU targets where allowed array size is 64K, but sizeint is 32K max.
This commit is contained in:
parent
40c359a551
commit
07dcd22b1c
@ -202,7 +202,10 @@ interface
|
||||
cguidconstnode : tguidconstnodeclass = tguidconstnode;
|
||||
cnilnode : tnilnodeclass=tnilnode;
|
||||
|
||||
function genintconstnode(const v : TConstExprInt) : tordconstnode;
|
||||
{ Creates tordconstnode with the smallest possible int type which can hold v }
|
||||
function genintconstnode(const v : TConstExprInt) : tordconstnode; overload;
|
||||
{ Creates tordconstnode with the preferredinttype type or a bigger type which can hold v }
|
||||
function genintconstnode(const v : TConstExprInt; preferredinttype : tdef) : tordconstnode; overload;
|
||||
function genenumnode(v : tenumsym) : tordconstnode;
|
||||
|
||||
{ some helper routines }
|
||||
@ -233,6 +236,17 @@ implementation
|
||||
end;
|
||||
|
||||
|
||||
function genintconstnode(const v : TConstExprInt; preferredinttype : tdef) : tordconstnode;
|
||||
var
|
||||
htype : tdef;
|
||||
begin
|
||||
int_to_type(v,htype);
|
||||
if htype.size<preferredinttype.size then
|
||||
htype:=preferredinttype;
|
||||
result:=cordconstnode.create(v,htype,true);
|
||||
end;
|
||||
|
||||
|
||||
function genenumnode(v : tenumsym) : tordconstnode;
|
||||
var
|
||||
htype : tdef;
|
||||
|
@ -2527,9 +2527,8 @@ implementation
|
||||
else if not is_open_array(left.resultdef) and
|
||||
not is_array_of_const(left.resultdef) and
|
||||
not is_dynamic_array(left.resultdef) then
|
||||
result:=cordconstnode.create(tarraydef(left.resultdef).highrange-
|
||||
tarraydef(left.resultdef).lowrange+1,
|
||||
sinttype,true);
|
||||
result:=genintconstnode(tarraydef(left.resultdef).highrange-
|
||||
tarraydef(left.resultdef).lowrange+1,sizesinttype);
|
||||
end;
|
||||
else
|
||||
;
|
||||
|
@ -465,12 +465,12 @@ implementation
|
||||
not((p1.nodetype = subscriptn) and
|
||||
is_packed_record_or_object(tsubscriptnode(p1).left.resultdef))) then
|
||||
begin
|
||||
statement_syssym:=cordconstnode.create(p1.resultdef.size,sizesinttype,true);
|
||||
statement_syssym:=genintconstnode(p1.resultdef.size,sizesinttype);
|
||||
if (l = in_bitsizeof_x) then
|
||||
statement_syssym:=caddnode.create(muln,statement_syssym,cordconstnode.create(8,sizesinttype,true));
|
||||
end
|
||||
else
|
||||
statement_syssym:=cordconstnode.create(p1.resultdef.packedbitsize,sizesinttype,true);
|
||||
statement_syssym:=genintconstnode(p1.resultdef.packedbitsize,sizesinttype);
|
||||
{ type def is a struct with generic fields }
|
||||
if df_has_generic_fields in p1.resultdef.defoptions then
|
||||
include(statement_syssym.flags,nf_generic_para);
|
||||
|
Loading…
Reference in New Issue
Block a user