* no rangecheck for openarrays with cdecl

This commit is contained in:
peter 2002-12-20 18:13:19 +00:00
parent 420fb26f38
commit 9666a05942

View File

@ -74,7 +74,7 @@ interface
private private
procedure rangecheck_array; procedure rangecheck_array;
protected protected
function get_mul_size : aword; function get_mul_size : longint;
{# This routine is used to calculate the address of the reference. {# This routine is used to calculate the address of the reference.
On entry reg contains the index in the array, On entry reg contains the index in the array,
and l contains the size of each element in the array. and l contains the size of each element in the array.
@ -505,7 +505,7 @@ implementation
TCGVECNODE TCGVECNODE
*****************************************************************************} *****************************************************************************}
function tcgvecnode.get_mul_size : aword; function tcgvecnode.get_mul_size : longint;
begin begin
if nf_memindex in flags then if nf_memindex in flags then
get_mul_size:=1 get_mul_size:=1
@ -556,42 +556,47 @@ implementation
var var
freereg : boolean; freereg : boolean;
hightree : tnode; hightree : tnode;
srsym : tsym;
poslabel, poslabel,
neglabel : tasmlabel; neglabel : tasmlabel;
hreg : tregister; hreg : tregister;
href : treference;
pushed : tpushedsaved; pushed : tpushedsaved;
begin begin
if is_open_array(left.resulttype.def) or if is_open_array(left.resulttype.def) or
is_array_of_const(left.resulttype.def) then is_array_of_const(left.resulttype.def) then
begin begin
{ Get high value } { cdecl functions don't have high() so we can not check the range }
hightree:=load_high_value(tvarsym(tloadnode(left).symtableentry)); if not(aktprocdef.proccalloption in [pocall_cdecl,pocall_cppdecl]) then
firstpass(hightree); begin
secondpass(hightree); { Get high value }
{ generate compares } hightree:=load_high_value(tvarsym(tloadnode(left).symtableentry));
freereg:=false; { it must be available }
if (right.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then if not assigned(hightree) then
hreg:=right.location.register internalerror(200212201);
else firstpass(hightree);
begin secondpass(hightree);
hreg := cg.get_scratch_reg_int(exprasmlist); { generate compares }
freereg:=true; freereg:=false;
cg.a_load_loc_reg(exprasmlist,right.location,hreg); if (right.location.loc in [LOC_REGISTER,LOC_CREGISTER]) then
end; hreg:=right.location.register
objectlibrary.getlabel(neglabel); else
objectlibrary.getlabel(poslabel); begin
cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_LT,0,hreg,poslabel); hreg := cg.get_scratch_reg_int(exprasmlist);
cg.a_cmp_loc_reg_label(exprasmlist,OS_INT,OC_BE,hightree.location,hreg,neglabel); freereg:=true;
if freereg then cg.a_load_loc_reg(exprasmlist,right.location,hreg);
cg.free_scratch_reg(exprasmlist,hreg); end;
cg.a_label(exprasmlist,poslabel); objectlibrary.getlabel(neglabel);
cg.a_call_name(exprasmlist,'FPC_RANGEERROR'); objectlibrary.getlabel(poslabel);
cg.a_label(exprasmlist,neglabel); cg.a_cmp_const_reg_label(exprasmlist,OS_INT,OC_LT,0,hreg,poslabel);
{ release hightree } cg.a_cmp_loc_reg_label(exprasmlist,OS_INT,OC_BE,hightree.location,hreg,neglabel);
location_release(exprasmlist,hightree.location); if freereg then
hightree.free; cg.free_scratch_reg(exprasmlist,hreg);
cg.a_label(exprasmlist,poslabel);
cg.a_call_name(exprasmlist,'FPC_RANGEERROR');
cg.a_label(exprasmlist,neglabel);
{ release hightree }
location_release(exprasmlist,hightree.location);
hightree.free;
end;
end end
else else
if is_dynamic_array(left.resulttype.def) then if is_dynamic_array(left.resulttype.def) then
@ -919,7 +924,10 @@ begin
end. end.
{ {
$Log$ $Log$
Revision 1.38 2002-12-17 22:19:33 peter Revision 1.39 2002-12-20 18:13:19 peter
* no rangecheck for openarrays with cdecl
Revision 1.38 2002/12/17 22:19:33 peter
* fixed pushing of records>8 bytes with stdcall * fixed pushing of records>8 bytes with stdcall
* simplified hightree loading * simplified hightree loading